Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST/PUT/PATCH Requests Override Content-Type Header #61

Open
gizmo385 opened this issue Apr 16, 2019 · 1 comment
Open

POST/PUT/PATCH Requests Override Content-Type Header #61

gizmo385 opened this issue Apr 16, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@gizmo385
Copy link

Currently, the POST, PUT, and PATCH methods automatically set the content-type header of any request (that doesn't explicitly supply content-type in the headers keyword argument) to application/json. This happens even if you provide extra_headers on the ConnectionProperties object that specify the content type.

This means that if you are sending POST/PATCH/PUT requests to a non-JSON API, your requests will be sent with application/json as the content-type without your knowledge. This can be confusing for users and cause needless head scratching.

@gene1wood gene1wood added the bug Something isn't working label Apr 16, 2019
@drice
Copy link

drice commented Aug 1, 2019

Possibly related, but header names should be case-insensitive. If a post is made with headers={"Content-Type": "application/xml"}, the post request checks if "content-type" is in headers and adds "content-type" of "application/json". When _fix_headers is called in the request method, it converts everything to lower case, copies to a temporary dict. The order of this operation cannot be known, so it's not deterministic whether the headers will contain "content-type" of "application/json" or "application/xml".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants