copied code from http://www.voidtrance.net/2010/01/simple-python-http-proxy/