Add support for proxies using HTTP_PROXY and fix URL encoding