[XMLHttpRequest] `HEAD` request doesn't work
See original GitHub issueThe same request works fine on iOS, on Android it fails with TypeError: Network request failed
. It used to work few version ago and no changes were done on the API or app side. Replacing the method from HEAD to GET and also making an extra endpoint on the API side temporarily resolves the issue (worth noting that the API handler itself stays unchanged, to the logic is the same)
AFAIK it has something to do with OkHTTP since: a) it works flawlessly on iOS b) it never reaches the API
I am not sure if that was fixed recently in OkHttp, but I guess it’s kind of a blocker until we upgrade to 3.x ?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:13 (7 by maintainers)
Top Results From Across the Web
XMLHttpRequest doesn't send some headers - Stack Overflow
I am testing the AJAX requests of my application but I cannot send some headers, for example Authorization header.
Read more >XMLHttpRequest - The Modern JavaScript Tutorial
XMLHttpRequest is a built-in browser object that allows to make HTTP requests in JavaScript. Despite having the word “XML” in its name, ...
Read more >How to send HTTP HEAD request? - JavaScript/AJAX - ReqBin
The HTTP HEAD requests, like an HTTP GET, cannot contain data in the message's body; the request data must be passed to the...
Read more >XMLHttpRequest.getResponseHeader() - Web APIs | MDN
The XMLHttpRequest method getResponseHeader() returns the string containing the text of a particular header's value.
Read more >XMLHttpRequest Standard
The XMLHttpRequest Standard defines an API that provides scripted client ... client . open ( "HEAD" , address ); client . send ();...
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 Free
Top 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
We are seeing this same error:
[TypeError: Network request failed]
in our HEAD requests in React Native 0.41.2I made a PR to fix the issue.
The problem is that the HEAD request do not have body and at this part of the code React Native will try to convert it to a string.
OkHttp
is not able to convert it and produces an exception.