pretenderjs / FakeXMLHttpRequest

A fake XMLHttpRequest object for testing in browsers
MIT License
65 stars 46 forks source link

check for lowercase content-type header #30

Closed sebastianhelbig closed 7 years ago

sebastianhelbig commented 7 years ago

In one of my projects we are using the github fetch polyfill (https://github.com/github/fetch) and setting a request Content-Type of application/x-www-form-urlencoded. In the polyfill code all custom set header names are made lowercase, this is according to specification (all header name are case insensitive (see: https://github.com/github/fetch/issues/249, https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2).

Current status is that FakeXMLHttpRequest only checks for case sensitive Content-Type. So in my project we end up with two content-type headers, resulting in a combined, invalid content-type of application/x-www-form-urlencoded, text/plain; charset=UTF-8.

This PR simply also checks for the lower-case variant.

cstolli commented 7 years ago

I would love to see this get merged! We could really use it. github/fetch users, same exact problem as OP.

sandersky commented 7 years ago

I went ahead and cut a new PR that addresses the PR concerns: https://github.com/pretenderjs/FakeXMLHttpRequest/pull/33

sebastianhelbig commented 7 years ago

Great! Thanks. Closing this in favour of #33