Skip to content

emscripten_fetch_unpack_response_headers returns header values with leading and trailing whitespace #27114

@Aerlinger

Description

@Aerlinger

The emscripten_fetch_unpack_response_headers function in emscripten's fetch API will return header values with a single leading whitespace character ( ) and a trailing CRLF character (\r\n\).

This will apply all headers in the response.

Example: application/json\r\n will be returned when application/json is expected.

Code Example to reproduce:

char** response_headers =
          emscripten_fetch_unpack_response_headers(some_buffer);

if (response_headers) {
  for (int header_num = 0; response_headers[header_num];
       header_num += 2) {
    std::string key = response_headers[header_num];
    std::string value = response_headers[header_num + 1];
    
    cout << value << endl;  // e.g. output " application/json\r\n"
  }
  emscripten_fetch_free_unpacked_response_headers(response_headers);
}

Version of emscripten/emsdk:
5.0.8-git

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions