From 4ea77b70b70501c0a701db837e77024de1e2fcf4 Mon Sep 17 00:00:00 2001 From: Emily Morehouse Date: Fri, 16 Feb 2018 17:18:58 -0700 Subject: [PATCH] Follow up to #1070: - Adding information in README for socketPath when used with a proxy - Adding an HTTP test for socketPath option --- README.md | 2 ++ test/unit/adapters/http.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/README.md b/README.md index d781aca418..5130b9a4c7 100755 --- a/README.md +++ b/README.md @@ -315,6 +315,8 @@ These are the available config options for making requests. Only the `url` is re // `socketPath` defines a UNIX Socket to be used in node.js. // e.g. '/var/run/docker.sock' to send requests to the docker daemon. + // Only either `socketPath` or `proxy` can be specified. + // If both are specified, `socketPath` is used. socketPath: null, // default // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index ae8238b433..11144cf62e 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -1,5 +1,6 @@ var axios = require('../../../index'); var http = require('http'); +var net = require('net'); var url = require('url'); var zlib = require('zlib'); var fs = require('fs'); @@ -228,6 +229,24 @@ module.exports = { }); }, + testSocket: function (test) { + server = net.createServer(function (socket) { + socket.on('data', function() { + socket.end('HTTP/1.1 200 OK\r\n\r\n'); + }); + }).listen('./test.sock', function() { + axios({ + socketPath: './test.sock', + url: '/' + }) + .then(function(resp) { + test.equal(resp.status, 200); + test.equal(resp.statusText, 'OK'); + test.done(); + }); + }); + }, + testStream: function(test) { server = http.createServer(function (req, res) { req.pipe(res);