2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

Merge branch 'instance-options' of github.com:codeclown/axios into instance-options

This commit is contained in:
Martti Laine
2018-03-09 13:58:35 +02:00
12 changed files with 84 additions and 17 deletions
Regular → Executable
+11 -2
View File
@@ -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';
@@ -128,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;
+5
View File
@@ -26,6 +26,7 @@ function getDefaultAdapter() {
}
var defaults = {
method: 'get',
adapter: getDefaultAdapter(),
transformRequest: [function transformRequest(data, headers) {
@@ -63,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',