Skip to content

fix(transformData): normalize headers with formatHeader to fix case-sensitivity issues#7544

Open
wdskuki wants to merge 1 commit intoaxios:v1.xfrom
wdskuki:fix/content-type-case-sensitivity
Open

fix(transformData): normalize headers with formatHeader to fix case-sensitivity issues#7544
wdskuki wants to merge 1 commit intoaxios:v1.xfrom
wdskuki:fix/content-type-case-sensitivity

Conversation

@wdskuki
Copy link

@wdskuki wdskuki commented Mar 22, 2026

Fixes #7393

The automatic URL-encoded serialization fails when the Content-Type header uses initial uppercase letters. This is because headers.normalize() was called without the formatHeader parameter.

Changes:

  • Export the formatHeader function from AxiosHeaders.js
  • Pass formatHeader to headers.normalize() in transformData.js

Summary by cubic

Normalize headers with formatHeader in transformData to fix case-sensitive Content-Type handling. Restores automatic URL-encoded serialization when header casing varies.

Description

  • Summary of changes
    • Export formatHeader from lib/core/AxiosHeaders.js.
    • Pass formatHeader to headers.normalize() in lib/core/transformData.js.
  • Reasoning
    • headers.normalize() without formatHeader failed to match mixed-case Content-Type, causing urlencoded serialization to be skipped.
  • Additional context

Testing

  • No tests added in this PR.
  • Add regression tests:
    • Ensure urlencoded serialization works with Content-Type, content-type, and other case variants.
    • Verify no change for already-lowercase headers.

Written for commit 2b0e2cd. Summary will update on new commits.

…ensitivity issues

Ensure headers are properly normalized with formatHeader during transformData.
This fixes issues where Content-Type headers with different casing (e.g.,
'Content-Type' vs 'content-type') were not being correctly recognized,
causing automatic serialization of urlencoded data to fail.

Fixes axios#7393
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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.

Automatic serialize urlencoded fails for "Content-Type" with initial upper case

1 participant