@lion/ajax has a problem with overwriting pre-existing headers in fetchJson
paulcodiny opened this issue · comments
Pavlik Kiselev commented
Expected behavior
It is possible to override Content-Type or Accept headers no matter how I write the headers because they are case-insensitive.
Actual Behavior
Because the "content-type" and "accept" are written in lowercase and are the keys of an object, it is possible to provide the same headers with a different case. This leads to a behavior when the Content-Type header has a value comma in the value, and that breaks some serves because it is against the specification.
How to reproduce
- Create an instance of ajax
- Call on it fetchJson('/any-url', { headers: { 'Content-Type': 'json' } });
- Check the "Content-Type" header in the resulting request. It will have comma in the value
Additional context
@lion/ajax v1.3.0