Skip to content

Instantly share code, notes, and snippets.

@thomaslorentsen
Created March 30, 2016 13:01
Show Gist options
  • Save thomaslorentsen/48c660f32df58d2c5ff55b1e9f32bfe1 to your computer and use it in GitHub Desktop.
Save thomaslorentsen/48c660f32df58d2c5ff55b1e9f32bfe1 to your computer and use it in GitHub Desktop.
var http = require('http');
var options = {
host: 'www.google.co.uk',
path: '/',
port: '80',
//This is the only line that is new. `headers` is an object with the headers to request
headers: {'auth': 'abc:123'}
};
callback = function(response) {
var str = '';
response.on('data', function (chunk) {
str += chunk;
});
console.log(response.headers['set-cookie']);
response.on('end', function () {
//console.log(str);
});
};
var req = http.request(options, callback);
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment