Skip to content

Compare HTTP header names case-insensitively - #205

Merged
resetius merged 1 commit into
masterfrom
http-headers-ci
Nov 11, 2026
Merged

resetius merged 1 commit into
masterfrom
http-headers-ci

Conversation

@resetius

@resetius resetius commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

What

Request and response header maps in coroio/http/httpd.hpp now use an ASCII case-insensitive transparent comparator (THeaderNameLess).
New aliases: THeaders (request, std::string_view keys, returned by TRequest::Headers()) and TResponseHeaders (response, std::string keys).

Why

Header field names are case-insensitive (RFC 9110, section 5.1). Before, Content-Length, Transfer-Encoding and Connection lookups missed content-length and similar spellings, so such requests were parsed without a body. The same applied to SetHeader("content-type", ...) after SetHeader("Content-Type", ...), which produced two headers.

Behaviour notes

  • Duplicate headers: the last value wins (unchanged); in the response map the first-seen spelling of the name is kept for output.
  • Response headers are still serialized in map order, which is now case-insensitive order.
  • Header values (chunked, close) are still compared exactly, as before.

Tests

tests/test_http.cpp: test_http_headers_case_insensitive (mixed-case request names, lookup by other case, body read via CONTENT-LENGTH), test_http_response_headers_case_insensitive (duplicate names in different case, serialization). Existing serialization tests are unchanged and pass; ut_test_http: 16/16 passed.

@resetius

Copy link
Copy Markdown
Owner Author

GitHub CI did not run, so here are local results on macOS 26.6.2, Apple clang 21.0.0 (Release, clean configure, all targets including examples and benchmarks built).

ctest: 100% passed, 4/4 (tests, test_actors, test_http, test_pipe), no flaky runs seen.

Sanity run of hello_httpd with mixed-case request headers (content-length: 5, connection: close on a POST with a body, and -H 'CONNECTION: close' via curl): both got 200 OK with Connection: close, and the server closed the connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant