Clean rebased version of https-proxy

This is a cleaned up version of #139 rebased against current master.