Performing a HEAD request with fetch causes an Invalid response for blob error on iOS
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.6.0
Yarn: Not Found
npm: 5.3.0
Watchman: 4.9.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.3.0-alpha.1 => 16.3.0-alpha.1
react-native: 0.54.0 => 0.54.0
Expected Behavior
The request should complete without error.
Actual Behavior
The RCTNetworking native module in iOS does not construct an empty blob for HEAD responses like Android does. Instead it returns an empty string as the response. However, whatwg-fetch always sets the responseType to blob for the XMLHttpRequest so the empty string is invalid.
Relevant lines of code:
https://github.com/github/fetch/blob/fcc4e1b48cfb5a2b1625fcd6eac06d954b00ccb6/fetch.js#L454
https://github.com/facebook/react-native/blob/6eef7de46ee5c5004854c1cdd5cd83f2a608f622/Libraries/Network/XMLHttpRequest.js#L253-L258
Invalid response for blob:
handleException @ index.bundle?platform=ios&dev=true&minify=false:13132
handleError @ index.bundle?platform=ios&dev=true&minify=false:12174
reportFatalError @ index.bundle?platform=ios&dev=true&minify=false:783
__guardSafe @ index.bundle?platform=ios&dev=true&minify=false:2360
callFunctionReturnFlushedQueue @ index.bundle?platform=ios&dev=true&minify=false:2165
t @ RNDebuggerWorker.js:1
Steps to Reproduce
1 Clone and run https://github.com/lingokids/FetchError
(I tested on an iPhone 7)
Performing a
HEADrequest withfetchcauses anInvalid response for bloberror on iOSEnvironment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.6.0
Yarn: Not Found
npm: 5.3.0
Watchman: 4.9.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.3.0-alpha.1 => 16.3.0-alpha.1
react-native: 0.54.0 => 0.54.0
Expected Behavior
The request should complete without error.
Actual Behavior
The RCTNetworking native module in iOS does not construct an empty blob for
HEADresponses like Android does. Instead it returns an empty string as the response. However,whatwg-fetchalways sets theresponseTypetoblobfor the XMLHttpRequest so the empty string is invalid.Relevant lines of code:
https://github.com/github/fetch/blob/fcc4e1b48cfb5a2b1625fcd6eac06d954b00ccb6/fetch.js#L454
https://github.com/facebook/react-native/blob/6eef7de46ee5c5004854c1cdd5cd83f2a608f622/Libraries/Network/XMLHttpRequest.js#L253-L258
Steps to Reproduce
1 Clone and run https://github.com/lingokids/FetchError
(I tested on an iPhone 7)