Headers all lowercased
See original GitHub issueBeen trying to debug an issue I’ve been having where the API I’m calling is returning a 500 error. Traced this down to this package. The server is expecting Content-Type
in Title-Case.
Node-fetch seems to lowercase all headers and that’s what it sends to the server on the way out.
Looking into #260 it shouldn’t be this way, as the fetch spec seemed to have been changed to insist on the headers remaining untouched (Which would be expected), however that issue was closed citing it’s a nodeJS issue… but the code in node-fetch is doing the toLowerCase()
call.
In my opinion and experience, if I set Content-Type
in my options, it should remain untouched and go through to the server like that.
Is there a work-around for now, or still waiting for a fix?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:7 (1 by maintainers)
Top GitHub Comments
For anyone else struggling with this issue, I have come up with a workaround:
There are probably a ton of situations where this will break code in weird ways, but for simple requests, it does the job. Hopefully node-fetch will be fixed so dodgy hacks like this are no longer necessary when trying to communicate with legacy devices!
According to RFC 2616, HTTP header names are case-insensitive. RFC 7540 states that HTTP2 header names must be lowercase and non-lowercase headers should be treated as malformed requests. You should raise this with the API developers since lowercase headers and case-insensitive header searches should be implemented.