Skip to content

Commit

Permalink
Revert ArrayBuffer support
Browse files Browse the repository at this point in the history
Summary:The ArrayBuffer support added in #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
  • Loading branch information
nicklockwood authored and Facebook Github Bot 2 committed Mar 2, 2016
1 parent e3de994 commit ca67648
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions Libraries/Network/XMLHttpRequestBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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');
Expand All @@ -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);
}
Expand Down

2 comments on commit ca67648

@tyao1
Copy link
Contributor

@tyao1 tyao1 commented on ca67648 Mar 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit breaks socket.io's long polling, either manually modify back this file or enable only websocket works for me.

@ide
Copy link
Contributor

@ide ide commented on ca67648 Mar 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to get this not-crashing on iOS 7 -- if anyone cares enough you should go do it.

Please sign in to comment.