Skip to content

Instantly share code, notes, and snippets.

@jimbru
Created April 21, 2014 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbru/11159763 to your computer and use it in GitHub Desktop.
Save jimbru/11159763 to your computer and use it in GitHub Desktop.
Nock Auth Issue
/**
* 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