mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Adding support for UNIX Sockets
This commit is contained in:
@@ -312,6 +312,10 @@ These are the available config options for making requests. Only the `url` is re
|
|||||||
// If set to 0, no redirects will be followed.
|
// If set to 0, no redirects will be followed.
|
||||||
maxRedirects: 5, // default
|
maxRedirects: 5, // default
|
||||||
|
|
||||||
|
// `socketPath` defines a UNIX Socket to be used in node.js.
|
||||||
|
// e.g. '/var/run/docker.sock' to send requests to the docker daemon.
|
||||||
|
socketPath: null, // default
|
||||||
|
|
||||||
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
||||||
// and https requests, respectively, in node.js. This allows options to be added like
|
// and https requests, respectively, in node.js. This allows options to be added like
|
||||||
// `keepAlive` that are not enabled by default.
|
// `keepAlive` that are not enabled by default.
|
||||||
|
|||||||
Regular → Executable
+7
-2
@@ -72,8 +72,6 @@ module.exports = function httpAdapter(config) {
|
|||||||
var agent = isHttps ? config.httpsAgent : config.httpAgent;
|
var agent = isHttps ? config.httpsAgent : config.httpAgent;
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
hostname: parsed.hostname,
|
|
||||||
port: parsed.port,
|
|
||||||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
||||||
method: config.method,
|
method: config.method,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@@ -81,6 +79,13 @@ module.exports = function httpAdapter(config) {
|
|||||||
auth: auth
|
auth: auth
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (config.socketPath) {
|
||||||
|
options.socketPath = config.socketPath;
|
||||||
|
} else {
|
||||||
|
options.hostname = parsed.hostname;
|
||||||
|
options.port = parsed.port;
|
||||||
|
}
|
||||||
|
|
||||||
var proxy = config.proxy;
|
var proxy = config.proxy;
|
||||||
if (!proxy && proxy !== false) {
|
if (!proxy && proxy !== false) {
|
||||||
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
||||||
|
|||||||
Reference in New Issue
Block a user