本文整理了Java中org.apache.commons.httpclient.HostConfiguration.setProxyHost()
方法的一些代码示例,展示了HostConfiguration.setProxyHost()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HostConfiguration.setProxyHost()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.HostConfiguration
类名称:HostConfiguration
方法名:setProxyHost
[英]Sets the given proxy host
[中]设置给定的代理主机
代码示例来源:origin: org.swordapp/sword-common
/**
* Clear the proxy setting.
*/
public void clearProxy() {
client.getHostConfiguration().setProxyHost(null);
}
代码示例来源:origin: org.dspace/dspace-sword-api
/**
* Clear the proxy setting.
*/
public void clearProxy() {
client.getHostConfiguration().setProxyHost(null);
}
代码示例来源:origin: org.apache.camel/camel-http
@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()));
}
}
}
代码示例来源:origin: stackoverflow.com
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
代码示例来源:origin: org.n52.security/52n-security-facade
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();
}
代码示例来源:origin: org.n52.security/52n-security-client
URL lURL = new URL(wasURLString);
ProxyHost proxy = proxyManager.getProxyHost(lURL);
client.getHostConfiguration().setProxyHost(proxy);
client.getState().setProxyCredentials(AuthScope.ANY,proxyManager.getProxyCredentials(lURL));
代码示例来源:origin: org.n52.security/52n-security-client
sLogger.debug("for server " + this.wssURLString + " not using proxy!");
client.getHostConfiguration().setProxyHost(proxy);
client.getState().setProxyCredentials(AuthScope.ANY, proxyManager.getProxyCredentials(lURL));
代码示例来源:origin: com.sun.jersey.contribs/jersey-apache-client
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;
}
}
代码示例来源:origin: org.n52.security/52n-security-facade
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()));
}
代码示例来源:origin: org.apache.portals.applications/apa-webcontent-jar
client.getHostConfiguration().setProxyHost(proxyHostObject);
代码示例来源:origin: org.n52.security/52n-security-facade
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()));
}
代码示例来源:origin: org.alfresco/alfresco-repository
hostConfig.setProxyHost(httpProxyHost);
hostConfig.setProxyHost(httpsProxyHost);
代码示例来源:origin: com.marvelution.jira.plugins/hudson-apiv2-wsclient
httpClient.getHostConfiguration().setProxyHost(proxyHost);
if (StringUtils.isNotBlank(System.getProperty("http.proxyUser"))) {
String user = System.getProperty("http.proxyUser");
代码示例来源:origin: org.n52.metadata/smarteditor-api
lConfig.setProxyHost(lProxyHost);
mClient.setHostConfiguration(lConfig);
LOG.debug("Using proxy: " + "Host={};Port={};Scheme={}"
代码示例来源:origin: Alfresco/alfresco-repository
hostConfig.setProxyHost(httpProxyHost);
hostConfig.setProxyHost(httpsProxyHost);
代码示例来源:origin: org.n52.metadata/smarteditor-api
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);
}
代码示例来源:origin: paultuckey/urlrewritefilter
if (proxyHost != null) config.setProxyHost(proxyHost);
代码示例来源:origin: org.tuckey/urlrewritefilter
if (proxyHost != null) config.setProxyHost(proxyHost);
代码示例来源:origin: com.googlecode.xremoting/xremoting-core
h = new ProxyHost(proxyHost, proxyPort);
httpClient.getHostConfiguration().setProxyHost(h);
代码示例来源:origin: org.zaproxy/zap
"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));
内容来源于网络,如有侵权,请联系作者删除!