Skip to content

Instantly share code, notes, and snippets.

@neerajsingh0101
Forked from phrawzty/2serv.py
Created July 5, 2016 13:52
Show Gist options
  • Save neerajsingh0101/92c48f50ba772955573acc50dd9fd1dc to your computer and use it in GitHub Desktop.
Save neerajsingh0101/92c48f50ba772955573acc50dd9fd1dc to your computer and use it in GitHub Desktop.
simple http server to dump request headers
$ curl -s -H "X-Something: yeah" localhost:8000 > /dev/null
$ python serv.py
ERROR:root:User-Agent: curl/7.37.1
Host: localhost:8000
Accept: */*
X-Something: yeah

127.0.0.1 - - [05/Mar/2015 11:28:33] "GET / HTTP/1.1" 200 -
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
logging.error(self.headers)
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
Handler = GetHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment