Example usage for org.apache.http.client.protocol RequestClientConnControl RequestClientConnControl

List of usage examples for org.apache.http.client.protocol RequestClientConnControl RequestClientConnControl

Introduction

In this page you can find the example usage for org.apache.http.client.protocol RequestClientConnControl RequestClientConnControl.

Prototype

public RequestClientConnControl() 

Source Link

Usage

From source file:org.siddhiesb.transport.http.conn.ProxyTunnelHandler.java

public ProxyTunnelHandler(final HttpRoute route,
        final org.siddhiesb.transport.http.conn.ClientConnFactory connFactory) {
    super();//from w w w  .j  ava  2 s. c  om
    this.route = route;
    this.connFactory = connFactory;
    this.httpProcessor = new ImmutableHttpProcessor(
            new HttpRequestInterceptor[] { new RequestClientConnControl() });
}

From source file:se.inera.certificate.proxy.filter.HttpProxyClient.java

@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent(true));
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestClientConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestAuthCache());
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}

From source file:edu.wisc.commons.httpclient.HrsDefaultHttpClient.java

/**
 * Override just to set RequestContent(true)
 *///from w  ww.j av a  2 s.com
@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent(true));
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestClientConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestAuthCache());
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}

From source file:org.yamj.api.common.http.AbstractPoolingHttpClient.java

@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent());
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestClientConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestAuthCache());
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}

From source file:com.gargoylesoftware.htmlunit.HttpWebConnection.java

private List<HttpRequestInterceptor> getHttpRequestInterceptors(final WebRequest webRequest)
        throws IOException {
    final List<HttpRequestInterceptor> list = new ArrayList<>();
    final Map<String, String> requestHeaders = webRequest.getAdditionalHeaders();
    final int port = webRequest.getUrl().getPort();
    final StringBuilder host = new StringBuilder(webRequest.getUrl().getHost());
    if (port != 80 && port > 0) {
        host.append(':');
        host.append(Integer.toString(port));
    }//from w w  w  .  ja  va  2s  .c o  m

    final String userAgent = webClient_.getBrowserVersion().getUserAgent();
    final String[] headerNames = webClient_.getBrowserVersion().getHeaderNamesOrdered();
    if (headerNames != null) {
        for (final String header : headerNames) {
            if ("Host".equals(header)) {
                list.add(new HostHeaderHttpRequestInterceptor(host.toString()));
            } else if ("User-Agent".equals(header)) {
                list.add(new UserAgentHeaderHttpRequestInterceptor(userAgent));
            } else if ("Accept".equals(header) && requestHeaders.get(header) != null) {
                list.add(new AcceptHeaderHttpRequestInterceptor(requestHeaders.get(header)));
            } else if ("Accept-Language".equals(header) && requestHeaders.get(header) != null) {
                list.add(new AcceptLanguageHeaderHttpRequestInterceptor(requestHeaders.get(header)));
            } else if ("Accept-Encoding".equals(header) && requestHeaders.get(header) != null) {
                list.add(new AcceptEncodingHeaderHttpRequestInterceptor(requestHeaders.get(header)));
            } else if ("Referer".equals(header) && requestHeaders.get(header) != null) {
                list.add(new RefererHeaderHttpRequestInterceptor(requestHeaders.get(header)));
            } else if ("Connection".equals(header)) {
                list.add(new RequestClientConnControl());
            } else if ("Cookie".equals(header)) {
                list.add(new RequestAddCookies());
            } else if ("DNT".equals(header) && webClient_.getOptions().isDoNotTrackEnabled()) {
                list.add(new DntHeaderHttpRequestInterceptor("1"));
            }
        }
    } else {
        list.add(new UserAgentHeaderHttpRequestInterceptor(userAgent));
        list.add(new RequestAddCookies());
        list.add(new RequestClientConnControl());
    }

    // not all browser versions have DNT by default as part of getHeaderNamesOrdered()
    // so we add it again, in case
    if (webClient_.getOptions().isDoNotTrackEnabled()) {
        list.add(new DntHeaderHttpRequestInterceptor("1"));
    }

    synchronized (requestHeaders) {
        list.add(new MultiHttpRequestInterceptor(new HashMap<>(requestHeaders)));
    }
    return list;
}

From source file:org.apache.http.impl.execchain.MainClientExec.java

public MainClientExec(final HttpRequestExecutor requestExecutor, final HttpClientConnectionManager connManager,
        final ConnectionReuseStrategy reuseStrategy, final ConnectionKeepAliveStrategy keepAliveStrategy,
        final AuthenticationStrategy targetAuthStrategy, final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler) {
    Args.notNull(requestExecutor, "HTTP request executor");
    Args.notNull(connManager, "Client connection manager");
    Args.notNull(reuseStrategy, "Connection reuse strategy");
    Args.notNull(keepAliveStrategy, "Connection keep alive strategy");
    Args.notNull(targetAuthStrategy, "Target authentication strategy");
    Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
    Args.notNull(userTokenHandler, "User token handler");
    this.authenticator = new HttpAuthenticator();
    this.proxyHttpProcessor = new ImmutableHttpProcessor(new RequestTargetHost(),
            new RequestClientConnControl());
    this.routeDirector = new BasicRouteDirector();
    this.requestExecutor = requestExecutor;
    this.connManager = connManager;
    this.reuseStrategy = reuseStrategy;
    this.keepAliveStrategy = keepAliveStrategy;
    this.targetAuthStrategy = targetAuthStrategy;
    this.proxyAuthStrategy = proxyAuthStrategy;
    this.userTokenHandler = userTokenHandler;
}

From source file:org.apache.http.impl.execchain.MinimalClientExec.java

public MinimalClientExec(final HttpRequestExecutor requestExecutor,
        final HttpClientConnectionManager connManager, final ConnectionReuseStrategy reuseStrategy,
        final ConnectionKeepAliveStrategy keepAliveStrategy) {
    Args.notNull(requestExecutor, "HTTP request executor");
    Args.notNull(connManager, "Client connection manager");
    Args.notNull(reuseStrategy, "Connection reuse strategy");
    Args.notNull(keepAliveStrategy, "Connection keep alive strategy");
    this.httpProcessor = new ImmutableHttpProcessor(new RequestContent(), new RequestTargetHost(),
            new RequestClientConnControl(), new RequestUserAgent(
                    VersionInfo.getUserAgent("Apache-HttpClient", "org.apache.http.client", getClass())));
    this.requestExecutor = requestExecutor;
    this.connManager = connManager;
    this.reuseStrategy = reuseStrategy;
    this.keepAliveStrategy = keepAliveStrategy;
}

From source file:org.apache.http.impl.nio.client.MainClientExec.java

public MainClientExec(final HttpProcessor httpProcessor, final HttpRoutePlanner routePlanner,
        final RedirectStrategy redirectStrategy, final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy, final UserTokenHandler userTokenHandler) {
    super();/*from w  w  w . j  a v  a2s.c om*/
    this.httpProcessor = httpProcessor;
    this.proxyHttpProcessor = new ImmutableHttpProcessor(new RequestTargetHost(),
            new RequestClientConnControl());
    this.routePlanner = routePlanner;
    this.redirectStrategy = redirectStrategy;
    this.targetAuthStrategy = targetAuthStrategy;
    this.proxyAuthStrategy = proxyAuthStrategy;
    this.userTokenHandler = userTokenHandler;
    this.routeDirector = new BasicRouteDirector();
    this.authenticator = new HttpAuthenticator(log);
}