Skip to content

Commit

Permalink
fix failure when running with NODE_DEBUG=request, and a test for that
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgm committed Sep 13, 2013
1 parent 21a6357 commit b8cf874
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/debug.js
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))
}
}
18 changes: 18 additions & 0 deletions tests/test-node-debug.js
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
})
})

0 comments on commit b8cf874

Please sign in to comment.