mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Prettier React Native Libraries
Reviewed By: sahrens Differential Revision: D7961488 fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
This commit is contained in:
committed by
Facebook Github Bot
parent
1e2de71290
commit
d01ab66b47
@@ -4,8 +4,10 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
'use strict';
|
||||
|
||||
const XMLHttpRequest = require('XMLHttpRequest');
|
||||
const originalXHROpen = XMLHttpRequest.prototype.open;
|
||||
@@ -96,43 +98,48 @@ const XHRInterceptor = {
|
||||
sendCallback(data, this);
|
||||
}
|
||||
if (this.addEventListener) {
|
||||
this.addEventListener('readystatechange', () => {
|
||||
if (!isInterceptorEnabled) {
|
||||
return;
|
||||
}
|
||||
if (this.readyState === this.HEADERS_RECEIVED) {
|
||||
const contentTypeString = this.getResponseHeader('Content-Type');
|
||||
const contentLengthString =
|
||||
this.getResponseHeader('Content-Length');
|
||||
let responseContentType, responseSize;
|
||||
if (contentTypeString) {
|
||||
responseContentType = contentTypeString.split(';')[0];
|
||||
this.addEventListener(
|
||||
'readystatechange',
|
||||
() => {
|
||||
if (!isInterceptorEnabled) {
|
||||
return;
|
||||
}
|
||||
if (contentLengthString) {
|
||||
responseSize = parseInt(contentLengthString, 10);
|
||||
}
|
||||
if (headerReceivedCallback) {
|
||||
headerReceivedCallback(
|
||||
responseContentType,
|
||||
responseSize,
|
||||
this.getAllResponseHeaders(),
|
||||
this,
|
||||
if (this.readyState === this.HEADERS_RECEIVED) {
|
||||
const contentTypeString = this.getResponseHeader('Content-Type');
|
||||
const contentLengthString = this.getResponseHeader(
|
||||
'Content-Length',
|
||||
);
|
||||
let responseContentType, responseSize;
|
||||
if (contentTypeString) {
|
||||
responseContentType = contentTypeString.split(';')[0];
|
||||
}
|
||||
if (contentLengthString) {
|
||||
responseSize = parseInt(contentLengthString, 10);
|
||||
}
|
||||
if (headerReceivedCallback) {
|
||||
headerReceivedCallback(
|
||||
responseContentType,
|
||||
responseSize,
|
||||
this.getAllResponseHeaders(),
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.readyState === this.DONE) {
|
||||
if (responseCallback) {
|
||||
responseCallback(
|
||||
this.status,
|
||||
this.timeout,
|
||||
this.response,
|
||||
this.responseURL,
|
||||
this.responseType,
|
||||
this,
|
||||
);
|
||||
if (this.readyState === this.DONE) {
|
||||
if (responseCallback) {
|
||||
responseCallback(
|
||||
this.status,
|
||||
this.timeout,
|
||||
this.response,
|
||||
this.responseURL,
|
||||
this.responseType,
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
},
|
||||
false,
|
||||
);
|
||||
}
|
||||
originalXHRSend.apply(this, arguments);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user