Created
December 2, 2012 01:37
-
-
Save danmilon/4186458 to your computer and use it in GitHub Desktop.
node outgoing headers lowercase or uppercase
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
/* | |
* Run tcpdump to capture outgoing HTTP headers first eg: | |
* "sudo tcpdump -vs 1024 -l -A dst www.google.com" (might need -i <interface>) | |
* | |
*/ | |
var http = require('http') | |
var options = { | |
hostname: 'www.google.com', | |
port: 80, | |
path: '/', | |
method: 'GET', | |
headers: { | |
AuThoRiZaTiOn: 'VaLuE' | |
} | |
} | |
var req = http.request(options, function(res) { | |
console.log('STATUS: ' + res.statusCode) | |
console.log('HEADERS: ' + JSON.stringify(res.headers)) | |
res.setEncoding('utf8') | |
res.on('data', function (chunk) { | |
console.log('BODY: ' + chunk) | |
}) | |
}) | |
req.on('error', function(e) { | |
console.log('problem with request: ' + e.message) | |
}) | |
req.end() |
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
$ node -p -e "process.versions" | |
{ http_parser: '1.0', | |
node: '0.8.11', | |
v8: '3.11.10.22', | |
ares: '1.7.5-DEV', | |
uv: '0.8', | |
zlib: '1.2.3', | |
openssl: '1.0.0f' } |
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
tcpdump: listening on wlan0, link-type EN10MB (Ethernet), capture size 1024 bytes | |
03:32:50.421786 IP (tos 0x0, ttl 64, id 62783, offset 0, flags [DF], proto TCP (6), length 60) | |
DANLAPTOP.local.56287 > muc03s01-in-f19.1e100.net.http: Flags [S], cksum 0x9330 (incorrect -> 0x56e3), seq 1391342967, win 14600, options [mss 1460,sackOK,TS val 3719240 ecr 0,nop,wscale 4], length 0 | |
E..<.?@[email protected]......#....PR.5w......9..0......... | |
.8.H........ | |
03:32:50.512939 IP (tos 0x0, ttl 64, id 62784, offset 0, flags [DF], proto TCP (6), length 52) | |
DANLAPTOP.local.56287 > muc03s01-in-f19.1e100.net.http: Flags [.], cksum 0x9328 (incorrect -> 0xec40), ack 3103798750, win 913, options [nop,nop,TS val 3719263 ecr 140957558], length 0 | |
E..4.@@.@.........#....PR.5x..5......(..... | |
.8._.f.v | |
03:32:50.513473 IP (tos 0x0, ttl 64, id 62785, offset 0, flags [DF], proto TCP (6), length 138) | |
DANLAPTOP.local.56287 > muc03s01-in-f19.1e100.net.http: Flags [P.], cksum 0x6bdd (correct), seq 0:86, ack 1, win 913, options [nop,nop,TS val 3719263 ecr 140957558], length 86 | |
E....A@.@..*......#....PR.5x..5.....k...... | |
.8._.f.vGET / HTTP/1.1 | |
AuThoRiZaTiOn: VaLuE | |
Host: www.google.com | |
Connection: keep-alive | |
03:32:50.622628 IP (tos 0x0, ttl 64, id 62786, offset 0, flags [DF], proto TCP (6), length 52) | |
DANLAPTOP.local.56287 > muc03s01-in-f19.1e100.net.http: Flags [.], cksum 0x9328 (incorrect -> 0xe713), ack 983, win 1036, options [nop,nop,TS val 3719290 ecr 140957665], length 0 | |
E..4.B@.@.........#....PR.5...9......(..... | |
.8.z.f.. | |
03:32:50.638029 IP (tos 0x0, ttl 64, id 62787, offset 0, flags [DF], proto TCP (6), length 52) | |
DANLAPTOP.local.56287 > muc03s01-in-f19.1e100.net.http: Flags [F.], cksum 0x9328 (incorrect -> 0xe70e), seq 86, ack 983, win 1036, options [nop,nop,TS val 3719294 ecr 140957665], length 0 | |
E..4.C@.@..~......#....PR.5...9......(..... | |
.8.~.f.. | |
03:32:50.725486 IP (tos 0x0, ttl 64, id 62788, offset 0, flags [DF], proto TCP (6), length 52) | |
DANLAPTOP.local.56287 > muc03s01-in-f19.1e100.net.http: Flags [.], cksum 0x9328 (incorrect -> 0xe68c), ack 984, win 1036, options [nop,nop,TS val 3719316 ecr 140957772], length 0 | |
E..4.D@.@..}......#....PR.5...9......(..... | |
.8...f.L | |
^C | |
6 packets captured | |
7 packets received by filter | |
0 packets dropped by kernel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment