Seeing your browser's headers using python

There's a very annoying website that won't send their CSS to my normal web browser (epiphany ) which makes it rather ugly. However when I use iceweasel the CSS gets applied. Since both browsers use exactly the same rendering engine, gecko, on my machine as far as I know, I thought they must sniff the headers sent by my browser. So I needed to check the headers, Python to the rescue:

import BaseHTTPServer

class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        self.wfile.write('<html><body><pre>')
        self.wfile.write(self.headers)
        self.wfile.write('</pre></body></html>')
        return

def main():
    try:
        server = BaseHTTPServer.HTTPServer(('', 80), MyHandler)
        print 'serving...'
        server.serve_forever()
    except KeyboardInterrupt:
        print 'ttfn'
        server.socket.close()

if __name__ == '__main__':
    main()

Running this as root (80 is a privileged port) will show you the headers sent by your browser to the server. It's so simple that it took me longer to write this post then to write that code.

Only a pity that it didn't help me solve my problem...