本文整理了Java中org.apache.commons.httpclient.ProxyHost.getProtocol()
方法的一些代码示例,展示了ProxyHost.getProtocol()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProxyHost.getProtocol()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.ProxyHost
类名称:ProxyHost
方法名:getProtocol
暂无
代码示例来源:origin: org.n52.metadata/smarteditor-api
, lProxyHost.getHostName()
, lProxyHost.getPort()
, lProxyHost.getProtocol().getScheme());
代码示例来源: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: Alfresco/alfresco-repository
public void testHTTPProxySettings()
{
String host = "testHost";
Integer port = 8080;
setHTTPSystemProperties(host, port, "user1", "password", null);
ProxyHost proxyHost = HttpClientHelper.createProxyHost("http.proxyHost", "http.proxyPort", DEFAULT_HTTP_PORT);
UsernamePasswordCredentials proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("http.proxyUser", "http.proxyPassword");
assertEquals(HTTP, proxyHost.getProtocol().getScheme());
assertEquals(host, proxyHost.getHostName());
assertEquals(port, Integer.valueOf(proxyHost.getPort()));
assertEquals("user1", proxyCredentials.getUserName());
assertEquals("password", proxyCredentials.getPassword());
// Test default port and no credentials
setHTTPSystemProperties(host, null, null, null, null);
proxyHost = HttpClientHelper.createProxyHost("http.proxyHost", "http.proxyPort", DEFAULT_HTTP_PORT);
proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("http.proxyUser", "http.proxyPassword");
assertEquals(HTTP, proxyHost.getProtocol().getScheme());
assertEquals(host, proxyHost.getHostName());
assertEquals(DEFAULT_HTTP_PORT, proxyHost.getPort());
assertNull(proxyCredentials);
}
代码示例来源:origin: Alfresco/alfresco-repository
public void testHTTPSProxySettings()
{
String host = "testHost";
Integer port = 8444;
setHTTPSSystemProperties(host, port, "user1", "password", null);
ProxyHost proxyHost = HttpClientHelper.createProxyHost("https.proxyHost", "https.proxyPort", DEFAULT_HTTPS_PORT);
UsernamePasswordCredentials proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("https.proxyUser", "https.proxyPassword");
// Proxy hosts always use plain HTTP connection when communicating with clients (by commons.httpclient doc)
assertEquals(HTTP, proxyHost.getProtocol().getScheme());
assertEquals(host, proxyHost.getHostName());
assertEquals(port, Integer.valueOf(proxyHost.getPort()));
assertEquals("user1", proxyCredentials.getUserName());
assertEquals("password", proxyCredentials.getPassword());
// Test default port and no credentials
setHTTPSSystemProperties(host, null, null, null, null);
proxyHost = HttpClientHelper.createProxyHost("https.proxyHost", "https.proxyPort", DEFAULT_HTTPS_PORT);
proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("https.proxyUser", "https.proxyPassword");
assertEquals(host, proxyHost.getHostName());
assertEquals(DEFAULT_HTTPS_PORT, proxyHost.getPort());
assertNull(proxyCredentials);
}
内容来源于网络,如有侵权,请联系作者删除!