Revert ArrayBuffer support

Summary:The ArrayBuffer support added in https://github.com/facebook/react-native/pull/6156 crashed on iOS7 as Uint8Array is unavailable.

This diff removes that feature. We can revisit it again once we drop support for iOS 7.

Reviewed By: javache

Differential Revision: D2999762

fb-gh-sync-id: b497eac92ca5a0865b308d2a08c9409fcce97156
shipit-source-id: b497eac92ca5a0865b308d2a08c9409fcce97156
This commit is contained in:
Nick Lockwood 2016-03-02 04:07:15 -08:00 committed by Facebook Github Bot 2
parent e3de994e69
commit ca67648f03

View File

@ -43,8 +43,8 @@ class XMLHttpRequestBase {
readyState: number;
responseHeaders: ?Object;
responseText: ?string;
response: string | ArrayBuffer | null;
responseType: '' | 'arraybuffer' | 'text';
response: ?string;
responseType: '' | 'text';
status: number;
timeout: number;
responseURL: ?string;
@ -143,15 +143,6 @@ class XMLHttpRequestBase {
}
}
_stringToArrayBuffer(str: string): ArrayBuffer {
var buffer = new ArrayBuffer(str.length);
var bufferView = new Uint8Array(buffer);
for (var i = 0, l = str.length; i < l; i++) {
bufferView[i] = str.charCodeAt(i);
}
return buffer;
}
_didReceiveData(requestId: number, responseText: string): void {
if (requestId === this._requestId) {
if (!this.responseText) {
@ -164,10 +155,7 @@ class XMLHttpRequestBase {
case 'text':
this.response = this.responseText;
break;
case 'arraybuffer': // NOTE: not supported by fetch
this.response = this._stringToArrayBuffer(this.responseText);
break;
default: //TODO: Support the other response type as well (eg:- document, json, blob)
default: //TODO: Support other types, eg: document, arraybuffer, json, blob
this.response = null;
}
this.setReadyState(this.LOADING);
@ -238,12 +226,6 @@ class XMLHttpRequestBase {
throw new Error('Subclass must define sendImpl method');
}
_uintToString(uintArray: Int8Array): string {
// $FlowFixMe - Function.apply accepts Int8Array, but Flow thinks it doesn't
var encodedString = String.fromCharCode.apply(null, uintArray);
return decodeURIComponent(encodedString);
}
send(data: any): void {
if (this.readyState !== this.OPENED) {
throw new Error('Request has not been opened');
@ -252,9 +234,6 @@ class XMLHttpRequestBase {
throw new Error('Request has already been sent');
}
this._sent = true;
if (data instanceof Int8Array) {
data = this._uintToString(data);
}
this.sendImpl(this._method, this._url, this._headers, data, this.timeout);
}