You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] javascript-flowtype and typescript-axios detect JSON POST body using case-sensitive header checking #6571
For the javascript-flowtype and typescript-axios generators, a POST request body is automatically passed into JSON.stringify() if the "Content-Type" header is "application/json." Sounds fine, but lets say you're overriding the content-type to something else like "multipart/formdata" by passing a generated header such as the one from the form-data package and it's all-lowercase - it doesn't match! The result is that your formdata (which is supposed to be plain text) gets JSON.stringified into a JSON string.
I don't think HTTP headers are supposed to be case-sensitive so while it might be technically a bit more expensive, I think the code ought to do a case-insensitive detection.
BTW Yes I tried explicitly setting content type in the spec file as an alternative, but for some reason this removed the body argument from my API, so I went back to */*.
Activity
benwiley4000 commentedon Jun 5, 2020
BTW Yes I tried explicitly setting content type in the spec file as an alternative, but for some reason this removed the
bodyargument from my API, so I went back to*/*.