Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up to #1070 - adding documentation and tests #1366

Merged
merged 1 commit into from Feb 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions 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');
Expand Down Expand Up @@ -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);
Expand Down