Skip to content

Commit

Permalink
Fix HEAD request failing with Invalid response for blob (facebook#1…
Browse files Browse the repository at this point in the history
…9567)

Summary:
Fixes facebook#18223

This is a fairly simple solution to what seems to be a recurring issue where certain requests that result in an empty body where JSON is expected throw an error rather than being handled gracefully. Client side error handling is not being hit as this is being thrown at a lower level.
Make a http request that results in an empty blob: ""

[INTERNAL] [BUGFIX] [XMLHttpRequest.js] - Line 262
Pull Request resolved: facebook#19567

Differential Revision: D8314416

Pulled By: hramos

fbshipit-source-id: a17c49f3620f0abbb936f3a1c2b01aa1b64820fd
  • Loading branch information
anthony authored and facebook-github-bot committed Sep 26, 2018
1 parent 4aac5fe commit 57149a6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Libraries/Network/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) {
case 'blob':
if (typeof this._response === 'object' && this._response) {
this._cachedResponse = BlobManager.createFromOptions(this._response);
} else {
} else if (this._response === '') {
this._cachedResponse = null;
} else {
throw new Error(`Invalid response for blob: ${this._response}`);
}
break;
Expand Down

0 comments on commit 57149a6

Please sign in to comment.