Case-insensitive header parsing needed
Being new to the Arduino ecosystem and not yet confident in my C++ skills, I'm unable to propose a pull request at this time. However, I wanted to share my investigation in case it proves helpful to others facing a similar problem.
The behavior I observed with client.responseBody() seemed to vary depending on the server I was communicating with. For a server sending { "test": 1234 }, the function returned:
10
{ "test": 1234 }
0
(indicating the hexadecimal size of the payload, the payload itself, and a null terminator).
Furthermore, the client.isResponseChunked() method, intended to indicate a transfer-encoding chunked response, sometimes returned 0 and other times 1.
Through investigation, I discovered that the relevant header in the response was transfer-encoding: chunked. The current code appears to be looking for the case-sensitive Transfer-Encoding: chunked.
https://github.com/arduino-libraries/ArduinoHttpClient/blob/8b76ac2c31724a4f399576996cf5938f29991132/src/HttpClient.h#L37
For reference, RFC 2616 section 4.2, HTTP header field names are defined to be case-insensitive. https://datatracker.ietf.org/doc/html/rfc2616#section-4.2
In my local testing, modifying #define HTTP_HEADER_TRANSFER_ENCODING "transfer-encoding" resolved the issue when interacting with my particular server. Enhancing the header parsing logic for case-insensitive comparisons of header field names would, I believe, eliminate a category of difficult-to-explain errors. I am uncertain whether HTTP_HEADER_CONTENT_LENGTH is subject to a similar issue.