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


Java HttpClientParams.setBooleanParameter方法代碼示例

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


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

示例1: constructHttpClient

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
protected HttpClient constructHttpClient()
{
    MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpClient httpClient = new HttpClient(connectionManager);
    HttpClientParams params = httpClient.getParams();
    params.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true);
    params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, true);
    if (socketTimeout != null) 
    {
        params.setSoTimeout(socketTimeout);
    }
    HttpConnectionManagerParams connectionManagerParams = httpClient.getHttpConnectionManager().getParams();
    connectionManagerParams.setMaxTotalConnections(maxTotalConnections);
    connectionManagerParams.setDefaultMaxConnectionsPerHost(maxHostConnections);
    connectionManagerParams.setConnectionTimeout(connectionTimeout);

    return httpClient;
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:19,代碼來源:HttpClientFactory.java

示例2: setUp

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception
{
    KeyStoreParameters keyStoreParameters = new KeyStoreParameters("SSL Key Store", "JCEKS", null, "ssl-keystore-passwords.properties", "ssl.keystore");
    KeyStoreParameters trustStoreParameters = new KeyStoreParameters("SSL Trust Store", "JCEKS", null, "ssl-truststore-passwords.properties", "ssl.truststore");
 
    SSLEncryptionParameters sslEncryptionParameters = new SSLEncryptionParameters(keyStoreParameters, trustStoreParameters);
    
    ClasspathKeyResourceLoader keyResourceLoader = new ClasspathKeyResourceLoader();
    HttpClientFactory httpClientFactory = new HttpClientFactory(SecureCommsType.getType("https"), sslEncryptionParameters, keyResourceLoader, null, null, "localhost", 8080,
            8443, 40, 40, 0);
    
    StringBuilder sb = new StringBuilder();
    sb.append("/solr/admin/cores");
    this.baseUrl = sb.toString();

    httpClient = httpClientFactory.getHttpClient();
    HttpClientParams params = httpClient.getParams();
    params.setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
    httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin"));
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:22,代碼來源:EmbeddedSolrTest.java

示例3: init

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
public void init()
{
    ParameterCheck.mandatory("baseUrl", baseUrl);
    
	StringBuilder sb = new StringBuilder();
	sb.append(baseUrl + "/admin/cores");
	this.adminUrl = sb.toString();

	httpClient = httpClientFactory.getHttpClient();
	HttpClientParams params = httpClient.getParams();
	params.setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
	httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin"));
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:14,代碼來源:SolrAdminHTTPClient.java

示例4: initClient

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
@Override
public void initClient(final ConnectionSettings settings) {
    if (settings == null)
        throw new NullPointerException("Internet connection settings cannot be null");
    this.settings = settings;
    final HttpClientParams clientParams = client.getParams();
    clientParams.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
    clientParams.setParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, true);
    clientParams.setSoTimeout(timeout);
    clientParams.setConnectionManagerTimeout(timeout);
    clientParams.setHttpElementCharset("UTF-8");
    this.client.setHttpConnectionManager(new SimpleHttpConnectionManager(/*true*/));
    this.client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);

    HttpState initialState = new HttpState();
    HostConfiguration configuration = new HostConfiguration();
    if (settings.getProxyType() == Proxy.Type.SOCKS) { // Proxy stuff happens here

        configuration = new HostConfigurationWithStickyProtocol();

        Proxy proxy = new Proxy(settings.getProxyType(), // create custom Socket factory
                new InetSocketAddress(settings.getProxyURL(), settings.getProxyPort())
        );
        protocol = new Protocol("http", new ProxySocketFactory(proxy), 80);

    } else if (settings.getProxyType() == Proxy.Type.HTTP) { // we use build in HTTP Proxy support          
        configuration.setProxy(settings.getProxyURL(), settings.getProxyPort());
        if (settings.getUserName() != null)
            initialState.setProxyCredentials(AuthScope.ANY, new NTCredentials(settings.getUserName(), settings.getPassword(), "", ""));
    }
    client.setHostConfiguration(configuration);

    clientParams.setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);

    client.setState(initialState);
}
 
開發者ID:jhkst,項目名稱:dlface,代碼行數:37,代碼來源:DownloadClient.java

示例5: HttpClientManager

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
/**
 * Constructor.
 */
public HttpClientManager() {
    client = new HttpClient();
    httpInfo = new HttpInfo(client);
    
    HttpClientParams clientParams = new HttpClientParams();
    clientParams.setBooleanParameter("http.protocol.allow-circular-redirects", true);
    client.setParams(clientParams);
}
 
開發者ID:huajun2013,項目名稱:ablaze,代碼行數:12,代碼來源:HttpClientManager.java

示例6: proxyLink

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
/**
 * Download link and have it be the response.
 * @param req the http request
 * @param resp the http response
 * @param link the link to download
 * @param c the cookie to set if any
 * @throws IOException on any error.
 */
private static void proxyLink(HttpServletRequest req, 
    HttpServletResponse resp, URI link, Cookie c, String proxyHost)
    throws IOException {
  org.apache.commons.httpclient.URI uri = 
    new org.apache.commons.httpclient.URI(link.toString(), false);
  HttpClientParams params = new HttpClientParams();
  params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
  params.setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
  HttpClient client = new HttpClient(params);
  // Make sure we send the request from the proxy address in the config
  // since that is what the AM filter checks against. IP aliasing or
  // similar could cause issues otherwise.
  HostConfiguration config = new HostConfiguration();
  InetAddress localAddress = InetAddress.getByName(proxyHost);
  if (LOG.isDebugEnabled()) {
    LOG.debug("local InetAddress for proxy host: " + localAddress.toString());
  }
  config.setLocalAddress(localAddress);
  HttpMethod method = new GetMethod(uri.getEscapedURI());
  method.setRequestHeader("Connection","close");
  @SuppressWarnings("unchecked")
  Enumeration<String> names = req.getHeaderNames();
  while(names.hasMoreElements()) {
    String name = names.nextElement();
    if(passThroughHeaders.contains(name)) {
      String value = req.getHeader(name);
      LOG.debug("REQ HEADER: "+name+" : "+value);
      method.setRequestHeader(name, value);
    }
  }

  String user = req.getRemoteUser();
  if(user != null && !user.isEmpty()) {
    method.setRequestHeader("Cookie",PROXY_USER_COOKIE_NAME+"="+
        URLEncoder.encode(user, "ASCII"));
  }
  OutputStream out = resp.getOutputStream();
  try {
    resp.setStatus(client.executeMethod(config, method));
    for(Header header : method.getResponseHeaders()) {
      resp.setHeader(header.getName(), header.getValue());
    }
    if(c != null) {
      resp.addCookie(c);
    }
    InputStream in = method.getResponseBodyAsStream();
    if(in != null) {
      IOUtils.copyBytes(in, out, 4096, true);
    }
  } finally {
    method.releaseConnection();
  }
}
 
開發者ID:Nextzero,項目名稱:hadoop-2.6.0-cdh5.4.3,代碼行數:62,代碼來源:WebAppProxyServlet.java

示例7: proxyLink

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
/**
 * Download link and have it be the response.
 * @param req the http request
 * @param resp the http response
 * @param link the link to download
 * @param c the cookie to set if any
 * @throws IOException on any error.
 */
private static void proxyLink(HttpServletRequest req, 
    HttpServletResponse resp, URI link, Cookie c, String proxyHost)
    throws IOException {
  org.apache.commons.httpclient.URI uri = 
    new org.apache.commons.httpclient.URI(link.toString(), false);
  HttpClientParams params = new HttpClientParams();
  params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
  params.setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
  HttpClient client = new HttpClient(params);
  // Make sure we send the request from the proxy address in the config
  // since that is what the AM filter checks against. IP aliasing or
  // similar could cause issues otherwise.
  HostConfiguration config = new HostConfiguration();
  InetAddress localAddress = InetAddress.getByName(proxyHost);
  if (LOG.isDebugEnabled()) {
    LOG.debug("local InetAddress for proxy host: " + localAddress.toString());
  }
  config.setLocalAddress(localAddress);
  HttpMethod method = new GetMethod(uri.getEscapedURI());

  @SuppressWarnings("unchecked")
  Enumeration<String> names = req.getHeaderNames();
  while(names.hasMoreElements()) {
    String name = names.nextElement();
    if(passThroughHeaders.contains(name)) {
      String value = req.getHeader(name);
      LOG.debug("REQ HEADER: "+name+" : "+value);
      method.setRequestHeader(name, value);
    }
  }

  String user = req.getRemoteUser();
  if(user != null && !user.isEmpty()) {
    method.setRequestHeader("Cookie",PROXY_USER_COOKIE_NAME+"="+
        URLEncoder.encode(user, "ASCII"));
  }
  OutputStream out = resp.getOutputStream();
  try {
    resp.setStatus(client.executeMethod(config, method));
    for(Header header : method.getResponseHeaders()) {
      resp.setHeader(header.getName(), header.getValue());
    }
    if(c != null) {
      resp.addCookie(c);
    }
    InputStream in = method.getResponseBodyAsStream();
    if(in != null) {
      IOUtils.copyBytes(in, out, 4096, true);
    }
  } finally {
    method.releaseConnection();
  }
}
 
開發者ID:ict-carch,項目名稱:hadoop-plus,代碼行數:62,代碼來源:WebAppProxyServlet.java

示例8: proxyLink

import org.apache.commons.httpclient.params.HttpClientParams; //導入方法依賴的package包/類
/**
 * Download link and have it be the response.
 * @param req the http request
 * @param resp the http response
 * @param link the link to download
 * @param c the cookie to set if any
 * @throws IOException on any error.
 */
private static void proxyLink(HttpServletRequest req, 
    HttpServletResponse resp, URI link, Cookie c, String proxyHost)
    throws IOException {
  org.apache.commons.httpclient.URI uri = 
    new org.apache.commons.httpclient.URI(link.toString(), false);
  HttpClientParams params = new HttpClientParams();
  params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
  params.setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
  HttpClient client = new HttpClient(params);
  // Make sure we send the request from the proxy address in the config
  // since that is what the AM filter checks against. IP aliasing or
  // similar could cause issues otherwise.
  HostConfiguration config = new HostConfiguration();
  InetAddress localAddress = InetAddress.getByName(proxyHost);
  if (LOG.isDebugEnabled()) {
    LOG.debug("local InetAddress for proxy host: " + localAddress.toString());
  }
  config.setLocalAddress(localAddress);
  HttpMethod method = new GetMethod(uri.getEscapedURI());
  @SuppressWarnings("unchecked")
  Enumeration<String> names = req.getHeaderNames();
  while(names.hasMoreElements()) {
    String name = names.nextElement();
    if(passThroughHeaders.contains(name)) {
      String value = req.getHeader(name);
      LOG.debug("REQ HEADER: "+name+" : "+value);
      method.setRequestHeader(name, value);
    }
  }

  String user = req.getRemoteUser();
  if(user != null && !user.isEmpty()) {
    method.setRequestHeader("Cookie",PROXY_USER_COOKIE_NAME+"="+
        URLEncoder.encode(user, "ASCII"));
  }
  OutputStream out = resp.getOutputStream();
  try {
    resp.setStatus(client.executeMethod(config, method));
    for(Header header : method.getResponseHeaders()) {
      resp.setHeader(header.getName(), header.getValue());
    }
    if(c != null) {
      resp.addCookie(c);
    }
    InputStream in = method.getResponseBodyAsStream();
    if(in != null) {
      IOUtils.copyBytes(in, out, 4096, true);
    }
  } finally {
    method.releaseConnection();
  }
}
 
開發者ID:chendave,項目名稱:hadoop-TCP,代碼行數:61,代碼來源:WebAppProxyServlet.java


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