当前位置: 首页>>代码示例>>Java>>正文


Java HttpParams.setParameter方法代码示例

本文整理汇总了Java中org.apache.http.params.HttpParams.setParameter方法的典型用法代码示例。如果您正苦于以下问题:Java HttpParams.setParameter方法的具体用法?Java HttpParams.setParameter怎么用?Java HttpParams.setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.params.HttpParams的用法示例。


在下文中一共展示了HttpParams.setParameter方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAsString

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
public String getAsString(String url) throws Exception {
    HttpGet get = new HttpGet(url);
    HttpParams params = new BasicHttpParams();
    params.setParameter("http.protocol.handle-redirects",false);
    get.setParams(params);
    HttpResponse r = httpClient.execute(get);
    return EntityUtils.toString(r.getEntity());
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:9,代码来源:HttpClientWrapper.java

示例2: createHTTPClient

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
private static AbstractHttpClient createHTTPClient() {
    AbstractHttpClient client = new DefaultHttpClient();
    String proxyHost = System.getProperty("https.proxyHost", "");
    if (!proxyHost.isEmpty()) {
        int proxyPort = Integer.parseInt(System.getProperty("https.proxyPort", "-1"));
        log.info("Using proxy " + proxyHost + ":" + proxyPort);
        HttpParams params = client.getParams();
        HttpHost proxy = new HttpHost(proxyHost, proxyPort);
        params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

        String proxyUser = System.getProperty(JMeter.HTTP_PROXY_USER, JMeterUtils.getProperty(JMeter.HTTP_PROXY_USER));
        if (proxyUser != null) {
            log.info("Using authenticated proxy with username: " + proxyUser);
            String proxyPass = System.getProperty(JMeter.HTTP_PROXY_PASS, JMeterUtils.getProperty(JMeter.HTTP_PROXY_PASS));

            String localHost;
            try {
                localHost = InetAddress.getLocalHost().getCanonicalHostName();
            } catch (Throwable e) {
                log.error("Failed to get local host name, defaulting to 'localhost'", e);
                localHost = "localhost";
            }

            AuthScope authscope = new AuthScope(proxyHost, proxyPort);
            String proxyDomain = JMeterUtils.getPropDefault("http.proxyDomain", "");
            NTCredentials credentials = new NTCredentials(proxyUser, proxyPass, localHost, proxyDomain);
            client.getCredentialsProvider().setCredentials(authscope, credentials);
        }
    }
    return client;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:32,代码来源:HttpUtils.java

示例3: getHttpClientInstance

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
public DefaultHttpClient getHttpClientInstance() {
    if (this.httpClient != null) {
        return this.httpClient;
    }
    HttpParams params = new BasicHttpParams();
    params.setParameter("http.connection.timeout", CONNECTION_TIMEOUT);
    params.setParameter("http.socket.timeout", SOCKET_TIMEOUT);
    params.setParameter("http.protocol.version", HttpVersion.HTTP_1_1);
    params.setParameter("http.useragent", "Apache-HttpClient/Android");
    params.setParameter("http.connection.stalecheck", Boolean.valueOf(false));
    this.httpClient = new DefaultHttpClient(params);
    this.httpClient.addRequestInterceptor(new GzipHttpRequestInterceptor());
    this.httpClient.addResponseInterceptor(new GzipHttpResponseInterceptor());
    this.httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
    return this.httpClient;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:17,代码来源:RestClient.java

示例4: setCredentialCharset

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
/**
 * Sets the charset to be used when encoding
 * {@link org.apache.http.auth.Credentials}.
 *
 * @param charset The charset
 */
public static void setCredentialCharset(final HttpParams params, final String charset) {
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    params.setParameter(AuthPNames.CREDENTIAL_CHARSET, charset);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:AuthParams.java

示例5: setMaxConnectionsPerRoute

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
/**
 * Sets lookup interface for maximum number of connections allowed per route.
 *
 * @param params HTTP parameters
 * @param connPerRoute lookup interface for maximum number of connections allowed
 *        per route
 */
public static void setMaxConnectionsPerRoute(final HttpParams params,
                                            final ConnPerRoute connPerRoute) {
    if (params == null) {
        throw new IllegalArgumentException
            ("HTTP parameters must not be null.");
    }
    params.setParameter(MAX_CONNECTIONS_PER_ROUTE, connPerRoute);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ConnManagerParams.java

示例6: getAsStringIfOk

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
public String getAsStringIfOk(String url) throws Exception {
    HttpGet get = new HttpGet(url);
    HttpParams params = new BasicHttpParams();
    params.setParameter("http.protocol.handle-redirects",false);
    get.setParams(params);
    HttpResponse r = httpClient.execute(get);
    String s = EntityUtils.toString(r.getEntity());
    if (r.getStatusLine().getStatusCode() == 200) {
        return s;
    } else {
        throw new RuntimeException(s);
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:14,代码来源:HttpClientWrapper.java

示例7: copyParams

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
/**
 * Copies the locally defined parameters to the argument parameters.
 * This method is called from {@link #clone()}.
 *
 * @param target    the parameters to which to copy
 * @since 4.2
 */
public void copyParams(HttpParams target) {
    Iterator<Map.Entry<String, Object>> iter = this.parameters.entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry<String, Object> me = iter.next();
        if (me.getKey() instanceof String)
            target.setParameter(me.getKey(), me.getValue());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:BasicHttpParams.java

示例8: setProxy

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
/**
 * Sets the Proxy by it's hostname,port,username and password
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 * @param username the username
 * @param password the password
 */
public void setProxy(String hostname, int port, String username, String password) {
    httpClient.getCredentialsProvider().setCredentials(
            new AuthScope(hostname, port),
            new UsernamePasswordCredentials(username, password));
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:17,代码来源:AsyncHttpClient.java

示例9: setProxy

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
/**
 * Sets the Proxy by it's hostname,port,username and password
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 * @param username the username
 * @param password the password
 */
public void setProxy(String hostname, int port, String username, String password) {
    httpClient.getCredentialsProvider().setCredentials(
        new AuthScope(hostname, port),
        new UsernamePasswordCredentials(username, password));
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:17,代码来源:AsyncHttpClient.java

示例10: setCookiePolicy

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
public static void setCookiePolicy(final HttpParams params, final String cookiePolicy) {
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    params.setParameter(ClientPNames.COOKIE_POLICY, cookiePolicy);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:HttpClientParams.java

示例11: setDefaultProxy

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
/**
 * Sets the {@link ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}
 * parameter value.
 *
 * @param params    the parameters in which to set the value
 * @param proxy     the value to set, may be <code>null</code>.
 *                  Note that {@link #NO_HOST} will be mapped to
 *                  <code>null</code> by {@link #getDefaultProxy},
 *                  to allow for explicit unsetting in hierarchies.
 */
public static void setDefaultProxy(HttpParams params,
                                         HttpHost proxy) {
    if (params == null) {
        throw new IllegalArgumentException("Parameters must not be null.");
    }
    params.setParameter(DEFAULT_PROXY, proxy);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ConnRouteParams.java

示例12: setProxy

import org.apache.http.params.HttpParams; //导入方法依赖的package包/类
/**
 * Sets the Proxy by it's hostname,port,username and password
 *
 * @param hostname the hostname (IP or DNS name)
 * @param port     the port number. -1 indicates the scheme default port.
 * @param username the username
 * @param password the password
 */
public void setProxy(String hostname, int port, String username, String password) {
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(hostname, port), new UsernamePasswordCredentials(username, password));
    final HttpHost proxy = new HttpHost(hostname, port);
    final HttpParams httpParams = this.httpClient.getParams();
    httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:15,代码来源:SyncHttpClient.java


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