emscripten-core / emscripten-core/emscripten
emscripten_fetch_unpack_response_headers returns header values with leading and trailing whitespace
- 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
Assessment
This issue has not been assessed yet.