-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Why remote the content-type when requestBody is empty ? #5814
Comments
Hey zWingz, what's the use case for defining a content type if there is no content? |
@NikoRaisanen Spring Boot will check the `content-type` So I have to set `content-type` even if there is no content in body |
may want to check the RFC https://www.rfc-editor.org/rfc/rfc7231#section-4.3.3 it is accepted that a post request would at least have a body of |
Hey @NikoRaisanen , would love to work on this issue. Can you please assign to me? |
I have the opposite problem. When I try to send a POST with no body, the request is sent with a |
Just set |
As far as I can tell, it does the same thing as setting it to null or an empty string (sends an empty header). |
@tlevesque-ueat The |
Yes, I realize that now. The tool I was using to inspect the request (webhook.site) was showing an empty Content-Type, but it doesn't seem to actually be present in the request. Thanks! |
Describe the issue
I have set
headers: { 'content-type': 'application/json' }
. But It can't be send to the server.And I found the code https://github.com/axios/axios/blob/v1.x/lib/adapters/xhr.js#L195 will remove the
content-type
when the request body is empty.Example Code
No response
Expected behavior
Still send the
content-type
to the server ?Axios Version
1.3.3
Adapter Version
xhr
Browser
chrome
Browser Version
latest
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: