Skip to content

Populate rawHeaders on ServerlessRequest - #315

Open
ganur2004 wants to merge 1 commit into
dougmoscrop:masterfrom
ganur2004:populate-raw-headers
Open

ganur2004 wants to merge 1 commit into
dougmoscrop:masterfrom
ganur2004:populate-raw-headers

Conversation

@ganur2004

Copy link
Copy Markdown

ServerlessRequest extends http.IncomingMessage and assigns headers, but never rawHeaders, so it stays the empty array from the base class. Anything that reads the standard rawHeaders property sees no headers at all, while req.headers looks normal.

This bites when the request is converted into a WHATWG Request, which is what @hono/node-server does. In our case an MCP server behind a Lambda Function URL answered every POST with "415 Unsupported Media Type: Content-Type must be application/json" while the health check kept working, because the conversion read rawHeaders and found nothing.

The fix rebuilds the flat [name, value, ...] list from the normalised headers object. The original casing and order are not recoverable at this point (providers normalise them first), but header names are case-insensitive, so this is a faithful enough IncomingMessage.

Includes a regression test; the full suite passes (117 tests).

ServerlessRequest extends http.IncomingMessage and assigns headers, but
never assigns rawHeaders, so it stays the empty array from the base class.
Anything that reads the standard rawHeaders property sees no headers at
all, while req.headers looks perfectly normal.

This bites when the request is converted into a WHATWG Request, which is
what @hono/node-server does and therefore what anything built on it does.
In our case an MCP server behind a Lambda Function URL answered every POST
with "415 Unsupported Media Type: Content-Type must be application/json"
while the health check kept working, because the conversion read
rawHeaders and found nothing.

The original casing and ordering of the wire headers is not recoverable
here: providers lower-case and merge them before the request is built. As
header names are case-insensitive, reconstructing the flat list from the
normalised object is a faithful enough IncomingMessage.
ganur2004 added a commit to ganur2004/safezone that referenced this pull request Oct 22, 2026
The submission went in on 22 October. SUBMISSION.md now says so, with
the links a reader would want: the Devpost page, the video, and the
public repository, which GitHub now reports as public under MIT.

The Open Source mini challenge is no longer blocked: the serverless-http
fix is open upstream as dougmoscrop/serverless-http#315, and DEVPOST.md
links to it.

Only the checklist items that were actually verified are ticked. A clean
clone build and the keyless demo were not re-run for this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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