HTTP Header with case-insensitive header names
See original GitHub issueHi, i’ve discovered another minor issue.
Describe the bug
define content-type: text/html
as response header results in duplicate content type header:
To Reproduce create a route that returns a html response like
return ({
headers: {
...filterProxyRequestHeaders(response.headers),
"content-type": "text/html"
},
body: bodyStream
});
Expected behavior
response contains only "content-type": "text/html"
as content type header.
Desktop (please complete the following information):
- OS => MacOS BigSur
- Package + Version
"@marblejs/core": "^3.4.8",
"@marblejs/middleware-body": "^3.4.8",
"@marblejs/middleware-logger": "^3.4.8",
- Node version =>
v14.12.0
Additional context i found this one as a short explainer that the headers in http protocol are case-insensitive: https://stackoverflow.com/a/5259004
My use case for a bit more context: I use undici a nodejs http client: https://github.com/nodejs/undici All response headers are in lower case letters and my plan is to forward them, as my marble server acts like a proxy in this case.
Workaround For now i can map the content-type header to the upper case one. But this can be tedious process if more headers are affected.
Let me know if i can help with that if you want to improve this.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Even tho It is technically a bugfix and a non breaking change according to the HTTP Spec I’d opt to introduce it gradually for the ☝🏻 mentioned reasons with service2service communication and test cases. I propose to patch the behavior change under a feature-toggle disabled by default with a sufficient warning linking to the issue, stating that It is going to be the default behavior in the X upcoming version and introduce it as a breaking change in the next minor/major.
One option would be to control it with an env variable, something like
Considering that the change affects only the HTTP server, It could also be a temporary optional server factory parameter
sorry for the late response - its a bit crazy at work currently. @JozefFlakus if you haven’t started yet, i can have a look at this in the upcoming weekend.
I like the idea from @DawidYerginyan to use a feature flag. I think an env variable would be a proper choice. With this solution the code must not be touched twice.