Skip to content

Conversation

@daltonpearson
Copy link

I realize this may be somewhat contentious, but I wanted to start with a workable solution before opening the discussion.

According to the HTTP/1.1 specification, header field names are case-insensitive, while in HTTP/2 they are required to be lowercase.

Currently, the tus client relies on case-sensitive indexing of headers, which causes issues in environments where backend stacks normalize headers to lowercase — a behavior already adopted by many frameworks and servers.

This PR introduces support for case-insensitive header lookups by normalizing header keys to lowercase when performing lookups.


⚙️ Summary

  • Ensures compatibility with HTTP/1.1 and HTTP/2 expectations

  • Fixes issues in backend setups where headers are automatically rewritten to lowercase

  • Aligns tus client behavior with common practice across HTTP client and server libraries


💬 Feedback Welcome

If there’s another approach the maintainers would prefer, please let me know — I’m happy to adjust the implementation to align with your preferred style or design direction.

@daltonpearson daltonpearson changed the title Fix: Make Header Indexing Case-Insensitive in tus Client WIP: Make Header Indexing Case-Insensitive in tus Client Nov 14, 2025
@Acconut
Copy link
Member

Acconut commented Nov 17, 2025

The case-insensitivity is usually handled by the HTTP client/server implementation through normalization so that the application logic (like tus-js-client) does not have to concern itself with the details. Is this not the case for you? What problem are you exactly running into? I would start from the direction instead of discussing a proposed solution directly.

@daltonpearson
Copy link
Author

@Acconut Our backend stack is normalizing the headers eg Location -> location, the problem is that tus is looking for the header "Location" instead of the normalized "location" therefore tus throws an error saying that the location/Location header is not set and fails.

@Acconut
Copy link
Member

Acconut commented Nov 17, 2025

Where do you use tus-js-client? In the browser, Node.is etc?

@daltonpearson daltonpearson force-pushed the case-insensitive-headers branch from 4616444 to 5756047 Compare November 17, 2025 22:19
@daltonpearson
Copy link
Author

In browser with a fast api backend.

@Acconut
Copy link
Member

Acconut commented Nov 17, 2025

That's odd because by default tus-js-client uses XMLHttpRequest in browsers, where the search for headers is case-insensitive: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getResponseHeader

The same is true for the Fetch API: https://developer.mozilla.org/en-US/docs/Web/API/Headers/get

I'm still not able to understand where exactly this problem seems to arise.

@daltonpearson
Copy link
Author

You're correct, we had some middleware running that was messing with the headers but not showing in dev tools. My apologies for wasting your time but on the bright side it did help us find our issue. If there's some way for us to buy you a coffee let me know. Closing this PR.

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.

2 participants