Skip to content

Instantly share code, notes, and snippets.

@mariyadiminsky
Last active July 20, 2016 05:52
Show Gist options
  • Save mariyadiminsky/01c7b490012353afe6d4e18b55df65d7 to your computer and use it in GitHub Desktop.
Save mariyadiminsky/01c7b490012353afe6d4e18b55df65d7 to your computer and use it in GitHub Desktop.
var http = require('http');
// STEP #2.2 Let's print the request headers from the request object. Uncomment below:
var bunnyServer = http.createServer();
bunnyServer.on('request', function(req, res) {
// printing the request headers!
console.log(req.headers);
// lets access the 'connection' property inside the headers object:
console.log("ACCESSING HEADER:", req.headers['connection']);
res.writeHead(200);
res.end('<html><body><h1>Bunny Server is live!</h1><img src="https://cdn.meme.am/instances/400x/55347780.jpg"></body></html>')
}).listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment