In case someone gives http_proxy as "http://hostname:port" but also gives us http_proxy_user, I split off the "http://" then URI.escape to percent encode "hostname:port" in case there are spaces/other bothersome things. The code is the same for https and ftp, so I used the general "scheme" parameter to denote which one we're doing.