• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HostParams类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.httpclient.params.HostParams的典型用法代码示例。如果您正苦于以下问题:Java HostParams类的具体用法?Java HostParams怎么用?Java HostParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HostParams类属于org.apache.commons.httpclient.params包,在下文中一共展示了HostParams类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.commons.httpclient.params.HostParams; //导入依赖的package包/类
private void init(final HostConfiguration hostConfiguration) {
    // wrap all of the assignments in a synchronized block to avoid
    // having to negotiate the monitor for each method call
    synchronized (hostConfiguration) {
        try {
            if (hostConfiguration.host != null) {
                this.host = (HttpHost) hostConfiguration.host.clone();
            } else {
                this.host = null;
            }
            if (hostConfiguration.proxyHost != null) {
                this.proxyHost = (ProxyHost) hostConfiguration.proxyHost.clone();
            } else {
                this.proxyHost = null;
            }
            this.localAddress = hostConfiguration.getLocalAddress();
            this.params = (HostParams)hostConfiguration.getParams().clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalArgumentException("Host configuration could not be cloned");
        }
    }        
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:23,代码来源:HostConfiguration.java


示例2: configureHttpClient

import org.apache.commons.httpclient.params.HostParams; //导入依赖的package包/类
protected void configureHttpClient() throws IOException, GeneralSecurityException {
    httpClient.getParams().setAuthenticationPreemptive(isAuthenticationPreemptive());
    initCredentials();
    initSocketFactory();
    initProtocolIfNeeded();
    if (httpConnectionManager != null) {
        httpClient.setHttpConnectionManager(httpConnectionManager);
    }

    List<Header> headers = getDefaultHeaders();

    httpClient.getHostConfiguration().getParams().setParameter(HostParams.DEFAULT_HEADERS, headers);
    httpClient.getParams().setParameter(HttpClientParams.USER_AGENT,
            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/11.04 Chromium/18.0.1025.151 Chrome/18.0.1025.151 Safari/535.19");
    httpClient.getParams().setParameter(HttpClientParams.HTTP_CONTENT_CHARSET, "UTF-8");
    httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

    httpClient.getParams().setConnectionManagerTimeout(connectionManagerTimeout);
    httpClient.getParams().setSoTimeout(soTimeout);
    if (connectionTimeout >= 0) {
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
    }
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:24,代码来源:HttpClientFactoryBean.java


示例3: HostConfiguration

import org.apache.commons.httpclient.params.HostParams; //导入依赖的package包/类
/**
 * Copy constructor for HostConfiguration
 * 
 * @param hostConfiguration the hostConfiguration to copy
 */
public HostConfiguration (final HostConfiguration hostConfiguration) {
    // wrap all of the assignments in a synchronized block to avoid
    // having to negotiate the monitor for each method call
    synchronized (hostConfiguration) {
        try {
            if (hostConfiguration.host != null) {
                this.host = (HttpHost) hostConfiguration.host.clone();
            } else {
                this.host = null;
            }
            if (hostConfiguration.proxyHost != null) {
                this.proxyHost = (ProxyHost) hostConfiguration.proxyHost.clone();
            } else {
                this.proxyHost = null;
            }
            this.localAddress = hostConfiguration.getLocalAddress();
            this.params = (HostParams)hostConfiguration.getParams().clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalArgumentException("Host configuration could not be cloned");
        }
    }        
}
 
开发者ID:magneticmoon,项目名称:httpclient3-ntml,代码行数:28,代码来源:HostConfiguration.java


示例4: testDefaultHeaders

import org.apache.commons.httpclient.params.HostParams; //导入依赖的package包/类
public void testDefaultHeaders() throws IOException {
    this.server.setHttpService(new SimpleService());

    ArrayList defaults = new ArrayList();
    defaults.add(new Header("this-header", "value1"));
    defaults.add(new Header("that-header", "value1"));
    defaults.add(new Header("that-header", "value2"));
    defaults.add(new Header("User-Agent", "test"));

    HostConfiguration hostconfig = new HostConfiguration();
    hostconfig.setHost(
            this.server.getLocalAddress(), 
            this.server.getLocalPort(),
            Protocol.getProtocol("http"));
    hostconfig.getParams().setParameter(HostParams.DEFAULT_HEADERS, defaults);
    
    GetMethod httpget = new GetMethod("/miss/");
    try {
        this.client.executeMethod(hostconfig, httpget);
    } finally {
        httpget.releaseConnection();
    }
    assertEquals(HttpStatus.SC_OK, httpget.getStatusCode());
    Header[] thisheader = httpget.getRequestHeaders("this-header");
    assertEquals(1, thisheader.length);
    Header[] thatheader = httpget.getRequestHeaders("that-header");
    assertEquals(2, thatheader.length);
    assertEquals("test", httpget.getRequestHeader("User-Agent").getValue());
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:30,代码来源:TestHttpParams.java


示例5: setCredentials

import org.apache.commons.httpclient.params.HostParams; //导入依赖的package包/类
private static void setCredentials(final @NotNull HttpClient httpClient,
                                   final @NotNull Credentials credentials,
                                   final @NotNull URI serverUri) {
  if (credentials.getType() == Credentials.Type.Alternate) {
    HostParams parameters = httpClient.getHostConfiguration().getParams();
    Collection<Header> headers = (Collection<Header>)parameters.getParameter(HostParams.DEFAULT_HEADERS);

    if (headers == null) {
      headers = new ArrayList<Header>();
      parameters.setParameter(HostParams.DEFAULT_HEADERS, headers);
    }

    Header authHeader = ContainerUtil.find(headers, new Condition<Header>() {
      @Override
      public boolean value(Header header) {
        return header.getName().equals(HTTPConstants.HEADER_AUTHORIZATION);
      }
    });

    if (authHeader == null) {
      authHeader = new Header(HTTPConstants.HEADER_AUTHORIZATION, "");
      headers.add(authHeader);
    }

    authHeader
      .setValue(BasicScheme.authenticate(new UsernamePasswordCredentials(credentials.getUserName(), credentials.getPassword()), "UTF-8"));
  }
  else {
    final NTCredentials ntCreds =
      new NTCredentials(credentials.getUserName(), credentials.getPassword(), serverUri.getHost(), credentials.getDomain());
    httpClient.getState().setCredentials(AuthScope.ANY, ntCreds);
    httpClient.getParams().setBooleanParameter(USE_NATIVE_CREDENTIALS, credentials.getType() == Credentials.Type.NtlmNative);
  }
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:35,代码来源:WebServiceHelper.java


示例6: setParams

import org.apache.commons.httpclient.params.HostParams; //导入依赖的package包/类
/**
 * Assigns {@link HostParams HTTP protocol parameters} specific to this host.
 * 
 * @since 3.0
 * 
 * @see HostParams
 */
public void setParams(final HostParams params) {
    if (params == null) {
        throw new IllegalArgumentException("Parameters may not be null");
    }
    this.params = params;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:14,代码来源:HostConfiguration.java


示例7: getParams

import org.apache.commons.httpclient.params.HostParams; //导入依赖的package包/类
/**
 * Returns {@link HostParams HTTP protocol parameters} associated with this host.
 *
 * @return HTTP parameters.
 *
 * @since 3.0
 */
public HostParams getParams() {
    return this.params;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:11,代码来源:HostConfiguration.java



注:本文中的org.apache.commons.httpclient.params.HostParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Pose类代码示例发布时间:2022-05-23
下一篇:
Java AShot类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap