Skip to content

fix: case-insensitive header lookup in parseBody - #378

Merged
hoegertn merged 1 commit into
mainfrom
fix/case-insensitive-header-lookup
Jul 29, 2026
Merged

fix: case-insensitive header lookup in parseBody#378
hoegertn merged 1 commit into
mainfrom
fix/case-insensitive-header-lookup

Conversation

@hoegertn

Copy link
Copy Markdown
Contributor

This pull request was created by @kiro-agent on behalf of @hoegertn 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro Web


Summary

Fixes #377parseBody used a case-sensitive bracket access (event.headers['content-type']) which missed canonically-cased Content-Type headers from API Gateway REST v1 proxy integrations.

Changes

  • Added a headerValue helper that finds headers case-insensitively (per RFC 9110 §5.1)
  • Updated parseBody to use the helper for content-type lookup
  • Updated corsHeader to use the same helper for origin lookup

Testing

  • TypeScript compiles cleanly (tsc --noEmit)
  • All 48 existing tests pass

HTTP header names are case-insensitive per RFC 9110 §5.1. API Gateway
REST (v1) proxy integrations pass headers with the client's original
casing. The parseBody function previously did a direct bracket access
for 'content-type' (lowercase only), which missed canonically-cased
'Content-Type' headers — silently passing an unparsed string body to
handlers that expect a parsed object.

Added a headerValue helper that finds headers case-insensitively and
applied it to both parseBody (content-type) and corsHeader (origin).

Closes #377

Co-authored-by: Thorsten Hoeger <thorsten.hoeger@taimos.de>
@hoegertn
hoegertn merged commit 087650a into main Jul 29, 2026
4 checks passed
@hoegertn
hoegertn deleted the fix/case-insensitive-header-lookup branch July 29, 2026 20:48
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.

parseBody misses a canonically-cased Content-Type header, silently passing an unparsed body to handlers

2 participants