/** * Clear the proxy setting. */ public void clearProxy() { client.getHostConfiguration().setProxyHost(null); }
/** * Clear the proxy setting. */ public void clearProxy() { client.getHostConfiguration().setProxyHost(null); }
@Override public void configureHttpClient(HttpClient client) { if (proxyHost.isPresent() && proxyPort.isPresent()) { client.getHostConfiguration().setProxyHost(new ProxyHost(proxyHost.get(), proxyPort.get())); } if (proxyHost.isPresent()) { client.getHostConfiguration().setProxyHost(new ProxyHost(proxyHost.get())); } } }
HttpClient client = new HttpClient(); HttpMethod method = new GetMethod(URIget); HostConfiguration hostCfg = new HostConfiguration(); HttpState state = client.getState(); //setting a proxy, for example: state.setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(getProxyUsername(), getProxyPassword())); hostCfg.setProxyHost(new ProxyHost(getProxyHost(), getProxyPort())); //method.getParams().setSoTimeout(timeout); for example a timeout client.executeMethod(hostCfg, method); //calling the server String resp = method.getResponseBodyAsString(); //the response body
private static InputStream requestDoc(URL url) throws IOException { HttpClient client = new HttpClient(); ProxyManager proxyManager = new ProxyManager(); ProxyHost proxy = proxyManager.getProxyHost(url); if (proxy != null) { LOG.debug("for server " + url + " using proxy: '" + proxy.getHostName() + "'"); } else { LOG.debug("for server " + url + " not using proxy!"); } client.getHostConfiguration().setProxyHost(proxy); client.getState().setProxyCredentials(AuthScope.ANY, proxyManager.getProxyCredentials(url)); GetMethod method = new GetMethod(url.toString()); client.executeMethod(method); return method.getResponseBodyAsStream(); }
URL lURL = new URL(wasURLString); ProxyHost proxy = proxyManager.getProxyHost(lURL); client.getHostConfiguration().setProxyHost(proxy); client.getState().setProxyCredentials(AuthScope.ANY,proxyManager.getProxyCredentials(lURL));
sLogger.debug("for server " + this.wssURLString + " not using proxy!"); client.getHostConfiguration().setProxyHost(proxy); client.getState().setProxyCredentials(AuthScope.ANY, proxyManager.getProxyCredentials(lURL));
private HostConfiguration getHostConfiguration(HttpClient client, Map<String, Object> props) { Object proxy = props.get(ApacheHttpClientConfig.PROPERTY_PROXY_URI); if (proxy != null) { URI proxyUri = getProxyUri(proxy); String proxyHost = proxyUri.getHost(); if (proxyHost == null) { proxyHost = "localhost"; } int proxyPort = proxyUri.getPort(); if (proxyPort == -1) { proxyPort = 8080; } HostConfiguration hostConfig = new HostConfiguration(client.getHostConfiguration()); String setHost = hostConfig.getProxyHost(); int setPort = hostConfig.getProxyPort(); if ((setHost == null) || (!setHost.equals(proxyHost)) || (setPort == -1) || (setPort != proxyPort)) { hostConfig.setProxyHost(new ProxyHost(proxyHost, proxyPort)); } return hostConfig; } else { return null; } }
private void initHttpClient() { m_client = new HttpClient(); ProxyManager proxyManager = new ProxyManager(); ProxyHost proxy = proxyManager.getProxyHost(m_endpointUrl); if (proxy != null) { LOG.debug("for server " + getURL() + " using proxy: '" + proxy.getHostName() + "'"); } else { LOG.debug("for server " + getURL() + " not using proxy!"); } m_client.getHostConfiguration().setProxyHost(proxy); m_client.getState().setProxyCredentials(AuthScope.ANY, proxyManager.getProxyCredentials(getURL())); }
client.getHostConfiguration().setProxyHost(proxyHostObject);
private void initHttpClient() { m_client = new HttpClient(); ProxyManager proxyManager = new ProxyManager(); ProxyHost proxy = proxyManager.getProxyHost(getURL()); if (proxy != null) { LOG.debug("for server " + getURL() + " using proxy: '" + proxy.getHostName() + "'"); } else { LOG.debug("for server " + getURL() + " not using proxy!"); } m_client.getHostConfiguration().setProxyHost(proxy); m_client.getState().setProxyCredentials(AuthScope.ANY, proxyManager.getProxyCredentials(getURL())); }
hostConfig.setProxyHost(httpProxyHost); hostConfig.setProxyHost(httpsProxyHost);
httpClient.getHostConfiguration().setProxyHost(proxyHost); if (StringUtils.isNotBlank(System.getProperty("http.proxyUser"))) { String user = System.getProperty("http.proxyUser");
lConfig.setProxyHost(lProxyHost); mClient.setHostConfiguration(lConfig); LOG.debug("Using proxy: " + "Host={};Port={};Scheme={}"
hostConfig.setProxyHost(httpProxyHost); hostConfig.setProxyHost(httpsProxyHost);
private void initClient() { this.setClient(new HttpClient()); HostConfiguration lConfig = new HostConfiguration(); ProxyResolver proxyResolver = new ProxyResolver(); try { URL lUrl = new URL(getEndpoint()); ProxyHost lProxyHost = proxyResolver.createProxyHost(lUrl); lConfig.setProxyHost(lProxyHost); if (lProxyHost != null) { LOG.debug("Using proxy: Host={}; Port{};Scheme={}", lProxyHost.getHostName(), lProxyHost.getPort(), lProxyHost.getProtocol().getScheme()); } else { LOG.debug("Using no proxy"); } // set proxy authentication, if any Credentials lCredentials = proxyResolver.createCredentials(lUrl); if (lCredentials != null) { LOG.info("Setting proxy credentials"); HttpState state = new HttpState(); state.setProxyCredentials(AuthScope.ANY, lCredentials); getClient().setState(state); } } catch (MalformedURLException pEx) { LOG.error("Error cleating proxy for URL " + getEndpoint() + ": " + pEx.getMessage()); } getClient().setHostConfiguration(lConfig); }
if (proxyHost != null) config.setProxyHost(proxyHost);
if (proxyHost != null) config.setProxyHost(proxyHost);
h = new ProxyHost(proxyHost, proxyPort); httpClient.getHostConfiguration().setProxyHost(h);
"https", (ProtocolSocketFactory) new SSLConnector(false), 443)); if (param.isUseProxy(hostName)) { hc.setProxyHost(new ProxyHost(param.getProxyChainName(), param.getProxyChainPort())); if (param.isUseProxyChainAuth()) { requestClient.getState().setProxyCredentials(getAuthScope(param), getNTCredentials(param));