Last active
August 29, 2015 14:03
-
-
Save domenic/2bb318b53946cf148279 to your computer and use it in GitHub Desktop.
Node's default HTTP request headers
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
"use strict"; | |
var http = require("http"); | |
http.createServer(function (req) { | |
console.log(req.headers); | |
}) | |
.listen(1337); | |
http.get('http://localhost:1337'); | |
// { host: 'localhost:1337', connection: 'close' } | |
var req = http.request({ hostname: 'localhost', port: 1337, path: '/', method: 'POST' }); | |
req.write('data'); | |
req.end(); | |
// { host: 'localhost:1337', connection: 'close', 'transfer-encoding': 'chunked' } | |
var req2 = http.request({ hostname: 'localhost', port: 1337, path: '/', method: 'POST', headers: { 'content-length': 4 } }); | |
req2.write('data'); | |
req2.end(); | |
// { 'content-length': 4, host: 'localhost:1337', connection: 'close' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment