mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
Merge branch 'master' into bugfix/allow-method-in-instance-config
This commit is contained in:
Regular → Executable
+14
-3
@@ -72,8 +72,6 @@ module.exports = function httpAdapter(config) {
|
||||
var agent = isHttps ? config.httpsAgent : config.httpAgent;
|
||||
|
||||
var options = {
|
||||
hostname: parsed.hostname,
|
||||
port: parsed.port,
|
||||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
||||
method: config.method,
|
||||
headers: headers,
|
||||
@@ -81,6 +79,13 @@ module.exports = function httpAdapter(config) {
|
||||
auth: auth
|
||||
};
|
||||
|
||||
if (config.socketPath) {
|
||||
options.socketPath = config.socketPath;
|
||||
} else {
|
||||
options.hostname = parsed.hostname;
|
||||
options.port = parsed.port;
|
||||
}
|
||||
|
||||
var proxy = config.proxy;
|
||||
if (!proxy && proxy !== false) {
|
||||
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
||||
@@ -117,7 +122,9 @@ module.exports = function httpAdapter(config) {
|
||||
}
|
||||
|
||||
var transport;
|
||||
if (config.maxRedirects === 0) {
|
||||
if (config.transport) {
|
||||
transport = config.transport;
|
||||
} else if (config.maxRedirects === 0) {
|
||||
transport = isHttps ? https : http;
|
||||
} else {
|
||||
if (config.maxRedirects) {
|
||||
@@ -126,6 +133,10 @@ module.exports = function httpAdapter(config) {
|
||||
transport = isHttps ? httpsFollow : httpFollow;
|
||||
}
|
||||
|
||||
if (config.maxContentLength && config.maxContentLength > -1) {
|
||||
options.maxBodyLength = config.maxContentLength;
|
||||
}
|
||||
|
||||
// Create the request
|
||||
var req = transport.request(options, function handleResponse(res) {
|
||||
if (req.aborted) return;
|
||||
|
||||
+1
-2
@@ -24,8 +24,7 @@ module.exports = function xhrAdapter(config) {
|
||||
// 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 (!window.XMLHttpRequest &&
|
||||
process.env.NODE_ENV !== 'test' &&
|
||||
if (process.env.NODE_ENV !== 'test' &&
|
||||
typeof window !== 'undefined' &&
|
||||
window.XDomainRequest && !('withCredentials' in request) &&
|
||||
!isURLSameOrigin(config.url)) {
|
||||
|
||||
@@ -64,6 +64,10 @@ var defaults = {
|
||||
return data;
|
||||
}],
|
||||
|
||||
/**
|
||||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||
* timeout is not created.
|
||||
*/
|
||||
timeout: 0,
|
||||
|
||||
xsrfCookieName: 'XSRF-TOKEN',
|
||||
|
||||
@@ -41,9 +41,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
|
||||
|
||||
if (utils.isArray(val)) {
|
||||
key = key + '[]';
|
||||
}
|
||||
|
||||
if (!utils.isArray(val)) {
|
||||
} else {
|
||||
val = [val];
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@ function forEach(obj, fn) {
|
||||
}
|
||||
|
||||
// Force an array if not already something iterable
|
||||
if (typeof obj !== 'object' && !isArray(obj)) {
|
||||
if (typeof obj !== 'object') {
|
||||
/*eslint no-param-reassign:0*/
|
||||
obj = [obj];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user