forked form https://code.google.com/p/python-proxy/