Skip to content

Commit

Permalink
Merge 5cc7b77 into bbb3a0b
Browse files Browse the repository at this point in the history
  • Loading branch information
willkan committed Apr 18, 2018
2 parents bbb3a0b + 5cc7b77 commit 0687d0a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -7,7 +7,7 @@
"util",
"utility"
],
"version": "2.85.1",
"version": "2.85.2",
"author": "Mikeal Rogers <mikeal.rogers@gmail.com>",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions request.js
Expand Up @@ -1331,9 +1331,9 @@ Request.prototype.getHeader = function (name, headers) {
}
Request.prototype.enableUnixSocket = function () {
// Get the socket & request paths from the URL
var unixParts = this.uri.path.split(':')
var host = unixParts[0]
var path = unixParts[1]
var colonIndex = this.uri.path.indexOf(':')
var host = this.uri.path.slice(0, colonIndex)
var path = this.uri.path.slice(colonIndex + 1)
// Apply unix properties to request
this.socketPath = host
this.uri.pathname = path
Expand Down
6 changes: 4 additions & 2 deletions tests/test-unix.js
Expand Up @@ -9,6 +9,7 @@ var tape = require('tape')
var url = require('url')

var rawPath = [null, 'raw', 'path'].join('/')
var rawPathSearch = '?foo=bar:bar'
var queryPath = [null, 'query', 'path'].join('/')
var searchString = '?foo=bar'
var socket = [__dirname, 'tmp-socket'].join('/')
Expand All @@ -21,7 +22,8 @@ var s = http.createServer(function (req, res) {
var incomingUrl = url.parse(req.url)
switch (incomingUrl.pathname) {
case rawPath:
assert.equal(incomingUrl.pathname, rawPath, 'requested path is sent to server')
assert.equal(incomingUrl.pathname, rawPath, 'requested pathname is sent to server')
assert.equal(incomingUrl.search, rawPathSearch, 'requested search is sent to server')
break

case queryPath:
Expand All @@ -43,7 +45,7 @@ tape('setup', function (t) {
})

tape('unix socket connection', function (t) {
request('http://unix:' + socket + ':' + rawPath, function (err, res, body) {
request('http://unix:' + socket + ':' + rawPath + rawPathSearch, function (err, res, body) {
t.equal(err, null, 'no error in connection')
t.equal(res.statusCode, statusCode, 'got HTTP 200 OK response')
t.equal(body, expectedBody, 'expected response body is received')
Expand Down

0 comments on commit 0687d0a

Please sign in to comment.