mirror of
https://github.com/tenrok/axios.git
synced 2026-05-27 14:47:43 +03:00
Remove ie8/9 special CORS treatment and btoa polyfill
This commit is contained in:
committed by
Khaled Garbaya
parent
0bb9aaf726
commit
5c754e6e07
+2
-19
@@ -6,7 +6,6 @@ var buildURL = require('./../helpers/buildURL');
|
||||
var parseHeaders = require('./../helpers/parseHeaders');
|
||||
var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
|
||||
var createError = require('../core/createError');
|
||||
var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
|
||||
|
||||
module.exports = function xhrAdapter(config) {
|
||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||
@@ -18,22 +17,6 @@ module.exports = function xhrAdapter(config) {
|
||||
}
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
var loadEvent = 'onreadystatechange';
|
||||
var xDomain = false;
|
||||
|
||||
// For IE 8/9 CORS support
|
||||
// Only supports POST and GET calls and doesn't returns the response headers.
|
||||
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
|
||||
if (process.env.NODE_ENV !== 'test' &&
|
||||
typeof window !== 'undefined' &&
|
||||
window.XDomainRequest && !('withCredentials' in request) &&
|
||||
!isURLSameOrigin(config.url)) {
|
||||
request = new window.XDomainRequest();
|
||||
loadEvent = 'onload';
|
||||
xDomain = true;
|
||||
request.onprogress = function handleProgress() {};
|
||||
request.ontimeout = function handleTimeout() {};
|
||||
}
|
||||
|
||||
// HTTP basic authentication
|
||||
if (config.auth) {
|
||||
@@ -48,8 +31,8 @@ module.exports = function xhrAdapter(config) {
|
||||
request.timeout = config.timeout;
|
||||
|
||||
// Listen for ready state
|
||||
request[loadEvent] = function handleLoad() {
|
||||
if (!request || (request.readyState !== 4 && !xDomain)) {
|
||||
request.onreadystatechange = function handleLoad() {
|
||||
if (!request || request.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user