set the proxy agent for each http request priority : 1 - proxyOptions 2 - proxyHttpEnv (HTTP_PROXY) 3 - proxyHttpsEnv (HTTPS_PROXY)
554037
function proxy(options) {
  var proxy = null
    , isSSL = false
    ;

  if (options.protocol === 'https:') {
    isSSL = true;
  }

  // Test the proxy parameter first for priority
  if (proxyOptions) {
    proxy = proxyOptions;
  } else {
    // Test proxy by env
    if (proxyHttpEnv) {
      proxy = proxyHttpEnv;
    } else if (proxyHttpsEnv) {
      proxy = proxyHttpsEnv;
    }
  }

  if (!proxy) {
    return;
  }

  if (isSSL) {
    options.agent = new HttpsProxyAgent(proxy);
  } else {
    options.agent = new HttpProxyAgent(proxy);
  }
}
838056
def http_proxy(self, value):
        
        self._verify_proxy_type_compatibility(ProxyType.MANUAL)
        self.proxyType = ProxyType.MANUAL
        self.httpProxy = value
1145256
def configure_proxy(proxy_setting, exceptions)
      ENV['HTTP_PROXY'] = proxy_setting
      ENV['http_proxy'] = proxy_setting
      ENV['HTTPS_PROXY'] = proxy_setting
      ENV['https_proxy'] = proxy_setting
      ENV['NO_PROXY'] = exceptions
      ENV['no_proxy'] = exceptions
      true
    end
1037833
public void setProxy(String host, int port, String user, String pwd) {
		this.proxy = new Proxy(host, port, user, pwd);
	}
718754
public function setProxy ($proxy_url, $socks5 = false)
	{
		curl_setopt($this->ch, CURLOPT_PROXY, $proxy_url);

		//set proxy to use socks5
		if ($socks5)
		{
			curl_setopt($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
		}
	}
116570
public void setHttpProxy(String httpProxy) {
		this.httpProxy = httpProxy;
		
		if (httpProxy == null) {
//			throw new IllegalArgumentException("'httpProxy' cannot be null");
			return;
		}
		
		String[] tokens = httpProxy.split(":");
		int count = tokens.length; 
		if (count == 1) {
			System.setProperty("http.proxyHost", tokens[0]);
		} else if (count == 2) {
			System.setProperty("http.proxyHost", tokens[0]);
			System.setProperty("http.proxyPort", tokens[1]);
		}		
	}
1229582
public ClientConfiguration withProxyProtocol(Protocol proxyProtocol) {
        this.proxyProtocol = proxyProtocol == null ? Protocol.HTTP : proxyProtocol;
        return this;
    }
1202825
@Override
   public HotRodServerConfigurationBuilder proxyHost(String proxyHost) {
      attributes.attribute(PROXY_HOST).set(proxyHost);
      return this;
   }
1149951
public void setProxy(URI proxy) {
        this.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxy.getHost(), proxy.getPort(), proxy.getScheme()));
    }
1369734
public static void setProxy(String proxyAddr) {
        if (proxyAddr != null) {
            Scanner s = new Scanner(proxyAddr);
            
            // Split into "proxyAddr:proxyPort".
            proxyAddr = null;
            int proxyPort = 8080;
            try {
                s.findInLine("(http://|)([^:/]+)(:|)([0-9]*)(/|)");
                MatchResult m = s.match();
                
                if (m.groupCount() >= 2) {
                    proxyAddr = m.group(2);
                }
                
                if ((m.groupCount() >= 4) && (!m.group(4).isEmpty()))  {
                    proxyPort = Integer.parseInt(m.group(4));
                }
            } finally {
                s.close();
            }
            
            if (proxyAddr != null) {
                SocketAddress sa = new InetSocketAddress(proxyAddr, proxyPort);
                setProxy(new Proxy(Type.HTTP, sa));
            }
        }
    }
1313240
async def get_http_proxy(cls) -> typing.Optional[str]:
        
        data = await cls.get_config("http_proxy")
        return None if data is None or data == "" else data
936294
def _proxy_settings(self):
        
        if not ('https_proxy' in environ or 'HTTPS_PROXY' in environ
                or 'http_proxy' in environ or 'HTTP_PROXY' in environ):
            return {}
        https_proxy = environ.get('https_proxy')
        if https_proxy is None:
            https_proxy = environ.get('HTTPS_PROXY')
        http_proxy = environ.get('http_proxy')
        if http_proxy is None:
            http_proxy = environ.get('HTTP_PROXY')
        no_proxy = environ.get('no_proxy')
        if no_proxy is None:
            no_proxy = environ.get('NO_PROXY', '')
        no_proxy = no_proxy + ',solr,db'

        out = [
            'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:'
            '/bin:/usr/games:/usr/local/games"\n']
        if https_proxy is not None:
            out.append('https_proxy=' + posix_quote(https_proxy) + '\n')
            out.append('HTTPS_PROXY=' + posix_quote(https_proxy) + '\n')
        if http_proxy is not None:
            out.append('http_proxy=' + posix_quote(http_proxy) + '\n')
            out.append('HTTP_PROXY=' + posix_quote(http_proxy) + '\n')
        if no_proxy is not None:
            out.append('no_proxy=' + posix_quote(no_proxy) + '\n')
            out.append('NO_PROXY=' + posix_quote(no_proxy) + '\n')

        with open(self.sitedir + '/run/proxy-environment', 'w') as f:
            f.write("".join(out))

        return {self.sitedir + '/run/proxy-environment': '/etc/environment'}
1350372
public void setProxy(String proxyHost, int proxyPort) {
        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", proxyHost);
        System.setProperty("http.proxyPort", "" + proxyPort);
        System.setProperty("https.proxyHost", proxyHost);
        System.setProperty("https.proxyPort", "" + proxyPort);
    }
1315016
private function setProxy($proxy, $onlyProtocol = null)
    {
        $proxy = trim($proxy);
        if (null == $onlyProtocol) {
            $this->proxySettings['http'] = $proxy;
            $this->proxySettings['https'] = $proxy;
        } else {
            $this->proxySettings[$onlyProtocol] = $proxy;
        }
    }
496851
public static function setProxy()
    {
        return [
            CURLOPT_PROXY => Config::get('larasap.proxy.hostname' , '127.0.0.1'),
            CURLOPT_PROXYPORT => Config::get('larasap.proxy.port' , '9050'),
            CURLOPT_PROXYTYPE => Config::get('larasap.proxy.type' , CURLPROXY_SOCKS5_HOSTNAME),
            CURLOPT_PROXYUSERPWD => Config::get('larasap.proxy.username').':'.Config::get('larasap.proxy.password'),
        ];
        
    }
1021471
public void setHTTPProxy(String PROXYNAME, int PROXYPORT) {
		if (PROXYNAME == null) {
			this.proxy_to_use = null;
		}
		else {
			this.proxy_to_use = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXYNAME, PROXYPORT));
		}
	}
1116873
def _prepare_proxy(self, conn):
        
        conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
        conn.connect()