Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header merging is case-sensitive, causing duplicate headers #125

Open
UppaJung opened this issue Sep 28, 2024 · 2 comments
Open

Header merging is case-sensitive, causing duplicate headers #125

UppaJung opened this issue Sep 28, 2024 · 2 comments

Comments

@UppaJung
Copy link

Some headers appear twice, once in lowercase and once in mixed-case, because some data structures provide them in lowercase, others in mixed-case, and the header-merging algorithm will include both the mixed-case and lowercase.

I discovered this issue while experimenting with porting/re-writing chrome-har in typescript and trying to replicate chrome-har's current behavior. Please feel free to compare against the typescript implementation to test the fix, or to adopt the code from it, which is also MIT license. (You're free to take the whole thing, but it's a very big change of coding style to adapt to if you don't like typescript.) Sorry that the first you are hearing from me is me filing bugs, but leaving them unreported seemed worse than the alternative.

@soulgalore
Copy link
Member

Hi @UppaJung thanks, do you have an example trace where the same header comes in different cases? We have code here https://github.com/sitespeedio/chrome-har/blob/main/lib/headers.js#L49-L63 that should have handled it but maybe it's not used everywhere?

@UppaJung
Copy link
Author

UppaJung commented Oct 4, 2024

I don't recall which of the existing traces I found this in.

The existing traces produce HARs with headers that are mixed-case, so you could just write a test case that asserts headerName.toLocaleLowercase() is equal to headerName for all existing traces and you should find examples.

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

No branches or pull requests

2 participants