-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite UNIX Domain Socket support into 2.33.1. Add test.
- Loading branch information
Ben Patterson
committed
Feb 7, 2014
1 parent
650e64b
commit 54e6dfb
Showing
3 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var assert = require('assert') | ||
, request = require('../index') | ||
, http = require('http') | ||
, fs = require('fs') | ||
; | ||
|
||
var path = [null, 'test', 'path'].join('/'); | ||
var socket = [__dirname, 'tmp-socket'].join('/'); | ||
var body = 'connected'; | ||
var statusCode = 200; | ||
|
||
var s = http.createServer(function(req, res) { | ||
// Assert requested path is sent to server | ||
assert.equal(req.url, path); | ||
res.statusCode = statusCode; | ||
res.end(body); | ||
}).listen(socket, function () { | ||
|
||
request(['unix://', socket, path].join(''), function (error, response, response_body) { | ||
// Assert no error in connection | ||
assert.equal(error, null); | ||
// Assert http success status code | ||
assert.equal(response.statusCode, statusCode); | ||
// Assert expected response body is recieved | ||
assert.equal(response_body, body); | ||
// clean up | ||
s.close(); | ||
fs.unlink(socket, function(){}); | ||
}) | ||
|
||
}) |