emscripten-core / emscripten-core/emscripten

emscripten_fetch_unpack_response_headers returns header values with leading and trailing whitespace

Open
#27,114 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

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:**

```cpp
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.