Created
April 21, 2014 23:15
-
-
Save jimbru/11159763 to your computer and use it in GitHub Desktop.
Nock Auth Issue
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
/** | |
* Demonstrates nock's auth header issue. | |
* -jimbru | |
*/ | |
var http = require('http'); | |
var nock = require('nock'); | |
function makeRequest(cb) { | |
var r = http.request( | |
{ | |
hostname: 'www.example.com', | |
path: '/', | |
method: 'GET', | |
auth: 'foo:bar' | |
}, | |
function(res) { | |
cb(res.req._headers); | |
} | |
); | |
r.end(); | |
} | |
makeRequest(function(h) { | |
console.log('===== NETWORK REQUEST ====='); | |
console.log(h); | |
console.log('\n'); | |
var n = nock('http://www.example.com').get('/').reply(200); | |
makeRequest(function(hNock) { | |
console.log('===== NOCK REQUEST ====='); | |
console.log(hNock); | |
console.log('\n'); | |
n.done(); | |
process.exit(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment