Skip to content

Conversation

abhishekmaniy
Copy link
Contributor

Suggested PR Description:

Summary

Fix response headers TypeScript types to use lowercase keys matching
runtime behavior.

Problem

Response headers are normalized to lowercase at runtime (as documented),
but TypeScript types incorrectly used Title Case headers, causing
type/runtime mismatches.

Solution

Change CommonResponseHeadersList to use lowercase header names:

  • 'Server''server'
  • 'Content-Type''content-type'
  • 'Content-Length''content-length'
  • etc.

Test case

const response = await axios.head(url);
// ✅ Now properly typed and has runtime value
const length = response.headers['content-length'];
// ❌ Title Case headers are undefined at runtime
const titleCase = response.headers['Content-Length']; // undefined

Fixes the TypeScript/runtime mismatch reported in the issue.

This minimal fix aligns the TypeScript definitions with axios's documented
and actual runtime behavior!

Change CommonResponseHeadersList to use lowercase header names to match
axios runtime behavior. Response headers are normalized to lowercase
as documented, but TypeScript types incorrectly used Title Case.

Fixes issue where response.headers['content-length'] had proper value
but was typed as 'any', while response.headers['Content-Length'] was
properly typed but undefined at runtime.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot added pr::fix PR that fixes a bug pr::types PR that changes project types definiton (.d.ts) labels Oct 7, 2025
@abhishekmaniy abhishekmaniy changed the title fix: correct response headers TypeScript types to use lowercase keys fix: correct response headers TypeScript types to use lowercase keys [Hacktoberfest] Oct 7, 2025
@jasonsaayman
Copy link
Member

jasonsaayman commented Oct 7, 2025

we actually need to solve for any case to work... i will keep this open sorry about the premature closing

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

Labels

pr::fix PR that fixes a bug pr::types PR that changes project types definiton (.d.ts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants