can i change the headers['content-type'] before a get request?
See original GitHub issueour back api limit the request content-type must be an fixed value, even it’s a get request.
but i see the source code will remove the content-type when request data is undefined,
so i set an empty data before request, like
if (!config.data) { config.data = "" }
then set the content-type . this will work well on IOS device; but crashed on android device,
it will throw an error,
GET must not have a request body
is there any solution to fix this problem? thanks~
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Content-Type - HTTP - MDN Web Docs - Mozilla
In responses, a Content-Type header provides the client with the actual content type of the returned content. This header's value may be ignored ......
Read more >Do I need a content-type header for HTTP GET requests?
GET requests can have "Accept" headers, which say which types of content the client understands. The server can then use that to decide ......
Read more >Content-Type Header Automatically Added to GET Requests
Click on any GET request to load it into the editor. Notice that there will be a Content-Type set in the Headers section....
Read more >HTTP/1.1: Header Field Definitions
The Accept request-header field can be used to specify certain media types which are acceptable for the response. Accept headers can be used...
Read more >Quickstart — Requests 2.28.1 documentation
Content-Length headers will be overridden when we can determine the length of the content. Furthermore, Requests does not change its behavior at all...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @HengCC,
I believe what you’re looking for is something like this:
Cheers 😄,
@delirius325 It does not gets sent as the header gets deleted here https://github.com/axios/axios/blob/98080381fa78dcffa91a15e6d25617583d13e533/dist/axios.js#L802
and if you would debug at this line before and after you would see this.