Skip to content

Case-insensitive header parsing needed #184

Open
@tjoyal

Description

@tjoyal

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.

#define HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions