Simple HTTP Proxy

Ruby's Webrick library includes an HTTP proxy class that you can very easily use. Here's a one-liner that does it all!

 ruby -r webrick/httpproxy -e 's = WEBrick::HTTPProxyServer.new(:Port => 8080, 
    :RequestCallback => Proc.new{|req,res| puts req.request_line, req.raw_header, req.body},
    :ProxyContentHandler => Proc.new{|req,res| puts "\n -- RESPONSE --\n", res.body, " -- \n\n"});
    trap("INT"){s.shutdown}; s.start'

I use this to intercept the requests my iPhone makes so that I can see what various apps are doing. My router doesn't support OpenWRT - otherwise I'd just use tcpdump.