-
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.
fix failure when running with NODE_DEBUG=request, and a test for that
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
var util = require('util') | ||
|
||
module.exports = | ||
function debug () { | ||
if (/\brequest\b/.test(process.env.NODE_DEBUG)) | ||
console.error('REQUEST %s', util.format.apply(util, arguments)) | ||
} | ||
} |
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,18 @@ | ||
var assert = require('assert') | ||
, request = require('../index') | ||
, http = require('http') | ||
; | ||
|
||
var s = http.createServer(function(req, res) { | ||
res.statusCode = 200 | ||
res.end('') | ||
}).listen(6767, function () { | ||
// a simple request should not fail with NODE_DEBUG | ||
process.env.NODE_DEBUG = 'mumblemumble,request' | ||
|
||
request('http://localhost:6767', function (err, resp, body) { | ||
assert.ifError(err, 'the request did not fail') | ||
assert.ok(resp, 'the request did not fail') | ||
s.close(); // clean up | ||
}) | ||
}) |