See Raw Headers with Netcat

October 5th, 2015
tech
Getting response headers is easy: run curl -D- -o/dev/null -sS [url] or load the site in a browser with the networking tab open. Getting request headers is harder, because webservers don't have a way to dump this exactly as they received it. Yes, you can set them to log specific headers, but logging all headers exactly as they came over the wire isn't something I see in nginx or apache. Netcat can help here. Start it up on some unused port:
    nc -lp 8070
Now make the thing you're debugging visit yoursite:8070. Netcat will print out what headers you got:
    GET / HTTP/1.1
    Host: www.jefftk.com:8070
    Referer: http://www.jefftk.com/...
    Accept-Encoding: gzip,deflate
    Cache-Control: no-store, no-cache
    Accept-Language: en-US
    Connection: Keep-alive
    Accept: */*
    Accept-Encoding: gzip,deflate
    ...
See the duplicate Accept-Encoding header? It turned out that A was adding an extra encoding header which then made B disable gzip. [1] Once I had the raw headers as sent it was pretty clear what the problem was.

(Because the problem was a duplicated header I'm glad I didn't go with a higher level tool that might have masked that problem by storing headers in hashtable or something.)


[1] Sniffing the traffic would have been ideal, but I wasn't in a position to get in between them.

Comment via: google plus, facebook

Recent posts on blogs I like:

Starting With Chords

A lot of people play fiddle. Basically nobody starts by learning chords before learning melodies. But that's actually how I learned. I started with chords. One of the nice things about learning to play violin this way is that you can go busking even…

via Anna Wise's Blog Posts November 15, 2024

Stuffies

I have some stuffies and I just have a bunny. Bunny is a rabbit. Woof is a seal. My favorite stuffie is bun bun. I play with my stuffies. Sometimes I jump up with them and I roll them. I can just throw them in the air when I want to play bthululubp wi…

via Nora Wise's Blog Posts November 15, 2024

You Can Buy A Malaria Net

2024 election takes

via Thing of Things November 6, 2024

more     (via openring)