當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpClient.setHostConfiguration方法代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.HttpClient.setHostConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpClient.setHostConfiguration方法的具體用法?Java HttpClient.setHostConfiguration怎麽用?Java HttpClient.setHostConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.httpclient.HttpClient的用法示例。


在下文中一共展示了HttpClient.setHostConfiguration方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: BitlyUrlShortenerImpl

import org.apache.commons.httpclient.HttpClient; //導入方法依賴的package包/類
public BitlyUrlShortenerImpl()
{
    httpClient = new HttpClient();
    httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
    HostConfiguration hostConfiguration = new HostConfiguration();
    hostConfiguration.setHost("api-ssl.bitly.com", 443, Protocol.getProtocol("https"));
    httpClient.setHostConfiguration(hostConfiguration);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:9,代碼來源:BitlyUrlShortenerImpl.java

示例2: getHttpsClient

import org.apache.commons.httpclient.HttpClient; //導入方法依賴的package包/類
protected HttpClient getHttpsClient(String httpsHost, int httpsPort)
{
    // Configure a custom SSL socket factory that will enforce mutual authentication
    HttpClient httpClient = constructHttpClient();
    HttpHostFactory hostFactory = new HttpHostFactory(new Protocol("https", sslSocketFactory, httpsPort));
    httpClient.setHostConfiguration(new HostConfigurationWithHostFactory(hostFactory));
    httpClient.getHostConfiguration().setHost(httpsHost, httpsPort, "https");
    return httpClient;
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:10,代碼來源:HttpClientFactory.java

示例3: buildClient

import org.apache.commons.httpclient.HttpClient; //導入方法依賴的package包/類
/**
 * Builds an HTTP client with the given settings. Settings are NOT reset to their default values after a client has
 * been created.
 * 
 * @return the created client.
 */
public HttpClient buildClient() {
    if (httpsProtocolSocketFactory != null) {
        Protocol.registerProtocol("https", new Protocol("https", httpsProtocolSocketFactory, 443));
    }

    HttpClientParams clientParams = new HttpClientParams();
    clientParams.setAuthenticationPreemptive(isPreemptiveAuthentication());
    clientParams.setContentCharset(getContentCharSet());
    clientParams.setParameter(HttpClientParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(
            connectionRetryAttempts, false));

    HttpConnectionManagerParams connMgrParams = new HttpConnectionManagerParams();
    connMgrParams.setConnectionTimeout(getConnectionTimeout());
    connMgrParams.setDefaultMaxConnectionsPerHost(getMaxConnectionsPerHost());
    connMgrParams.setMaxTotalConnections(getMaxTotalConnections());
    connMgrParams.setReceiveBufferSize(getReceiveBufferSize());
    connMgrParams.setSendBufferSize(getSendBufferSize());
    connMgrParams.setTcpNoDelay(isTcpNoDelay());

    MultiThreadedHttpConnectionManager connMgr = new MultiThreadedHttpConnectionManager();
    connMgr.setParams(connMgrParams);

    HttpClient httpClient = new HttpClient(clientParams, connMgr);

    if (proxyHost != null) {
        HostConfiguration hostConfig = new HostConfiguration();
        hostConfig.setProxy(proxyHost, proxyPort);
        httpClient.setHostConfiguration(hostConfig);

        if (proxyUsername != null) {
            AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort);
            UsernamePasswordCredentials proxyCredentials = new UsernamePasswordCredentials(proxyUsername,
                    proxyPassword);
            httpClient.getState().setProxyCredentials(proxyAuthScope, proxyCredentials);
        }
    }

    return httpClient;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:46,代碼來源:HttpClientBuilder.java


注:本文中的org.apache.commons.httpclient.HttpClient.setHostConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。