Example usage for org.apache.http.params HttpParams removeParameter

List of usage examples for org.apache.http.params HttpParams removeParameter

Introduction

In this page you can find the example usage for org.apache.http.params HttpParams removeParameter.

Prototype

boolean removeParameter(String str);

Source Link

Usage

From source file:gmusic.api.comm.ApacheConnector.java

public ApacheConnector() {
    HttpParams params = new BasicHttpParams();
    params.removeParameter("User-Agent");
    params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
    // HttpConnectionParams.setConnectionTimeout(params, 150000);
    // HttpConnectionParams.setSoTimeout(params, socketTimeoutMillis);
    httpClient = new DefaultHttpClient(params);
    cookieStore = new BasicCookieStore();
    localContext = new BasicHttpContext();
    localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
}

From source file:gmusic.api.api.comm.ApacheConnector.java

public ApacheConnector() {
    final HttpParams params = new BasicHttpParams();
    params.removeParameter("User-Agent");
    params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
    // HttpConnectionParams.setConnectionTimeout(params, 150000);
    // HttpConnectionParams.setSoTimeout(params, socketTimeoutMillis);
    httpClient = new DefaultHttpClient(params);
    cookieStore = new BasicCookieStore();
    localContext = new BasicHttpContext();
    localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
}

From source file:com.archivas.clienttools.arcutils.impl.adapter.HCAPAdapter.java

/**
 * Sets an int parameter on the http client, use null to clear
 * /*from w w w .  j ava2  s  .c o m*/
 * @param timeout
 *            The new timeout
 */
protected void setIntClientParameter(final Integer timeout, final String parameter) {
    HttpParams params = httpClient.getParams();
    if (timeout != null) {
        params.setIntParameter(parameter, timeout);
    } else {
        params.removeParameter(parameter);
    }
    httpClient.setParams(params);
}

From source file:org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.java

/**
 * Setup following elements on httpRequest:
 * <ul>//from  w w w .  jav  a2s  .  c  om
 * <li>ConnRoutePNames.LOCAL_ADDRESS enabling IP-SPOOFING</li>
 * <li>Socket and connection timeout</li>
 * <li>Redirect handling</li>
 * <li>Keep Alive header or Connection Close</li>
 * <li>Calls setConnectionHeaders to setup headers</li>
 * <li>Calls setConnectionCookie to setup Cookie</li>
 * </ul>
 * 
 * @param url
 *            {@link URL} of the request
 * @param httpRequest
 *            http request for the request
 * @param res
 *            sample result to set cookies on
 * @throws IOException
 *             if hostname/ip to use could not be figured out
 */
protected void setupRequest(URL url, HttpRequestBase httpRequest, HTTPSampleResult res) throws IOException {

    HttpParams requestParams = httpRequest.getParams();

    // Set up the local address if one exists
    final InetAddress inetAddr = getIpSourceAddress();
    if (inetAddr != null) {// Use special field ip source address (for pseudo 'ip spoofing')
        requestParams.setParameter(ConnRoutePNames.LOCAL_ADDRESS, inetAddr);
    } else if (localAddress != null) {
        requestParams.setParameter(ConnRoutePNames.LOCAL_ADDRESS, localAddress);
    } else { // reset in case was set previously
        requestParams.removeParameter(ConnRoutePNames.LOCAL_ADDRESS);
    }

    int rto = getResponseTimeout();
    if (rto > 0) {
        requestParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, rto);
    }

    int cto = getConnectTimeout();
    if (cto > 0) {
        requestParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, cto);
    }

    requestParams.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, getAutoRedirects());

    // a well-behaved browser is supposed to send 'Connection: close'
    // with the last request to an HTTP server. Instead, most browsers
    // leave it to the server to close the connection after their
    // timeout period. Leave it to the JMeter user to decide.
    if (getUseKeepAlive()) {
        httpRequest.setHeader(HTTPConstants.HEADER_CONNECTION, HTTPConstants.KEEP_ALIVE);
    } else {
        httpRequest.setHeader(HTTPConstants.HEADER_CONNECTION, HTTPConstants.CONNECTION_CLOSE);
    }

    setConnectionHeaders(httpRequest, url, getHeaderManager(), getCacheManager());

    String cookies = setConnectionCookie(httpRequest, url, getCookieManager());

    if (res != null) {
        res.setCookies(cookies);
    }

}