question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[XMLHttpRequest] `HEAD` request doesn't work

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
gijoehosaphatcommented, Feb 21, 2017

We are seeing this same error: [TypeError: Network request failed] in our HEAD requests in React Native 0.41.2

0reactions
SandroMachadocommented, Jun 1, 2017

I 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found