Created
March 30, 2016 13:01
-
-
Save thomaslorentsen/48c660f32df58d2c5ff55b1e9f32bfe1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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