ThingHTTP server response header using "Transfer-Encoding: chunked"

Zachariah Belding on 15 Dec 2022
Latest activity Reply by Zachariah Belding on 15 Dec 2022

When making a ThingHttp request via POST, the server response header does not include: "Content-Length:". Instead it is using "Transfer-Encoding: chunked". This makes it dificult to confirm that the entire response has been recieved. Any way to change this?
21:09:55.812 -> POST /apps/thinghttp/send_request HTTP/1.1
21:09:55.812 -> Host: api.thingspeak.com
21:09:55.812 -> Content-Type: application/x-www-form-urlencoded
21:09:55.812 -> Content-Length: 60
21:09:55.812 ->
21:09:55.812 -> headers=false&api_key=[removed]&message=Arduino Reset
21:09:55.906 ->
21:09:57.040 ->
21:09:57.040 ->
21:09:57.040 -> HTTP/1.1 200 OK
21:09:57.040 -> Date: Thu, 15 Dec 2022 02:09:57 GMT
21:09:57.040 -> Content-Type: text/html; charset=utf-8
21:09:57.040 -> Transfer-Encoding: chunked
21:09:57.040 -> Connection: keep-alive
21:09:57.040 -> Status: 200 OK
21:09:57.040 -> Cache-Control: max-age=0, private, must-revalidate
21:09:57.040 -> X-Request-Id: 798bbb62-da97-4ff8-a15b-c60b68fd60d3
21:09:57.040 -> ETag: W/"408e73c03e9c23fc2318c396c21c09e8"
21:09:57.040 ->
21:09:57.040 -> 2d
21:09:57.040 -> Congratulations! You've fired the alert event
21:09:57.040 -> 0
21:09:57.040 ->
Christopher Stapels
Christopher Stapels on 15 Dec 2022 (Edited on 15 Dec 2022)
There is no control for the headers used in ThingHTTP, though you can ask ThingSpeak to reduce the headers sent to a device in some cases.
I would guess that the client that is accepting the ThingHTTP request should be able to do the right HTTP thing. Are you writing a custom receiver/client? Does it run on a device?
If you really needed to send length information, you can be able to calculate the length in a MATLAB analysis, and then use webread and webwrite to send the response to your device or whomever else is listening. You can control the headers explicitly in MATLAB.
Zachariah Belding
Zachariah Belding on 15 Dec 2022
Thanks, yes this is a custom library written for an LTE Modem.
As a more broad question, do you know why "Transfer-Encoding: chunked" is being used at all? This is usually only used for large amounts of data or for streaming. I have never seen it used for APIs.
According to these two sources, "chunked" is be depreciated:
https://everything.curl.dev/http/post/chunked
"This assumes that you know you do this against an HTTP/1.1 server. Before 1.1, there was no chunked encoding, and after version 1.1 chunked encoding has been deprecated."
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding
"Note: HTTP/2 disallows all uses of the Transfer-Encoding header"