Java 类org.apache.http.HttpResponseInterceptor 实例源码

项目:cmc-claim-store    文件:HttpClientConfiguration.java   
private CloseableHttpClient getHttpClient() {
    int timeout = 10000;
    RequestConfig config = RequestConfig.custom()
        .setConnectTimeout(timeout)
        .setConnectionRequestTimeout(timeout)
        .setSocketTimeout(timeout)
        .build();

    return HttpClientBuilder
        .create()
        .useSystemProperties()
        .addInterceptorFirst(new OutboundRequestIdSettingInterceptor())
        .addInterceptorFirst((HttpRequestInterceptor) new OutboundRequestLoggingInterceptor())
        .addInterceptorLast((HttpResponseInterceptor) new OutboundRequestLoggingInterceptor())
        .setDefaultRequestConfig(config)
        .build();
}
项目:RenewPass    文件:MechanizeAgent.java   
/**
 * This method is used to capture Location headers after HttpClient redirect handling.
 */
private void setupClient(final AbstractHttpClient client) {
    this.client.addResponseInterceptor(new HttpResponseInterceptor() {
        @Override
        public void process(final HttpResponse response, final HttpContext context)
                throws HttpException, IOException {
            Header header = response.getFirstHeader("Location");
            if (header!=null) {
                String location = header.getValue();

                /*
                 * Append the base name to the Location header
                 */
                if (location.startsWith("/")) {
                    String baseUrl = context.getAttribute(ExecutionContext.HTTP_TARGET_HOST).toString();
                    location = baseUrl + location;
                }
                context.setAttribute("Location", location);
            }
        }
    });
}
项目:purecloud-iot    文件:TestResponseContentEncoding.java   
@Test
public void testContentEncodingRequestParameter() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    final StringEntity original = new StringEntity("encoded stuff");
    original.setContentEncoding("GZip");
    response.setEntity(original);

    final RequestConfig config = RequestConfig.custom()
            .setDecompressionEnabled(false)
            .build();

    final HttpContext context = new BasicHttpContext();
    context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);

    final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
    interceptor.process(response, context);
    final HttpEntity entity = response.getEntity();
    Assert.assertNotNull(entity);
    Assert.assertFalse(entity instanceof GzipDecompressingEntity);
}
项目:purecloud-iot    文件:TestResponseProcessCookies.java   
@Test
public void testParseCookies() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(1, cookies.size());
    final Cookie cookie = cookies.get(0);
    Assert.assertEquals(0, cookie.getVersion());
    Assert.assertEquals("name1", cookie.getName());
    Assert.assertEquals("value1", cookie.getValue());
    Assert.assertEquals("localhost", cookie.getDomain());
    Assert.assertEquals("/", cookie.getPath());
}
项目:purecloud-iot    文件:TestResponseProcessCookies.java   
@Test
public void testNoCookieOrigin() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(0, cookies.size());
}
项目:purecloud-iot    文件:TestResponseProcessCookies.java   
@Test
public void testNoCookieSpec() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(0, cookies.size());
}
项目:purecloud-iot    文件:TestResponseProcessCookies.java   
@Test
public void testNoCookieStore() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, null);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(0, cookies.size());
}
项目:purecloud-iot    文件:TestResponseProcessCookies.java   
@Test
public void testSetCookie2OverrideSetCookie() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE, "name1=value1");
    response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertEquals(1, cookies.size());
    final Cookie cookie = cookies.get(0);
    Assert.assertEquals(1, cookie.getVersion());
    Assert.assertEquals("name1", cookie.getName());
    Assert.assertEquals("value2", cookie.getValue());
    Assert.assertEquals("localhost.local", cookie.getDomain());
    Assert.assertEquals("/", cookie.getPath());
}
项目:purecloud-iot    文件:TestResponseProcessCookies.java   
@Test
public void testInvalidHeader() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertTrue(cookies.isEmpty());
}
项目:purecloud-iot    文件:TestResponseProcessCookies.java   
@Test
public void testCookieRejected() throws Exception {
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
    response.addHeader(SM.SET_COOKIE2, "name=value; Domain=www.somedomain.com; Version=1");

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
    context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);

    final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
    interceptor.process(response, context);

    final List<Cookie> cookies = this.cookieStore.getCookies();
    Assert.assertNotNull(cookies);
    Assert.assertTrue(cookies.isEmpty());
}
项目:dsworkbench    文件:ReportServer.java   
public RequestListenerThread(int port, final String docroot) throws IOException {
    this.serversocket = new ServerSocket(port);
    this.params = new SyncBasicHttpParams();
    this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

    // Set up the HTTP protocol processor
    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]{
        new ResponseDate(),
        new ResponseServer(),
        new ResponseContent(),
        new ResponseConnControl()
    });

    // Set up request handlers
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpFileHandler());

    // Set up the HTTP service
    this.httpService = new HttpService(
            httpproc,
            new DefaultConnectionReuseStrategy(),
            new DefaultHttpResponseFactory(),
            reqistry,
            this.params);
}
项目:gen-server-http-listener    文件:RequestListenerThread.java   
/**
 * Default constructor which specifies the <code>port</code> to listen to
 * for requests and the <code>handlers</code>, which specify how to handle
 * the request.
 * 
 * @param port
 *            the port to listen to
 * @param handlers
 *            the handlers, which specify how to handle the different
 *            requests
 * 
 * @throws IOException
 *             if some IO operation fails
 */
public RequestListenerThread(final int port,
        final Map<String, IHandler> handlers) throws IOException {
    super(port);

    // Set up the HTTP protocol processor
    final HttpProcessor httpproc = new ImmutableHttpProcessor(
            new HttpResponseInterceptor[] { new ResponseDate(),
                    new ResponseServer(), new ResponseContent(),
                    new ResponseConnControl() });

    // Set up request handlers
    UriHttpRequestHandlerMapper registry = new UriHttpRequestHandlerMapper();
    for (final Entry<String, IHandler> entry : handlers.entrySet()) {
        registry.register(entry.getKey(), entry.getValue());
    }

    // Set up the HTTP service
    httpService = new HttpService(httpproc, registry);
    connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
}
项目:RedditInPictures    文件:RESTService.java   
/**
 * From apache examples
 *
 * @return
 *
 * @see <a
 * href="http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientGZipContentCompression.java">Apache
 * examples</a>
 */
private HttpResponseInterceptor getGzipResponseInterceptor() {
    return new HttpResponseInterceptor() {

        public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                Header ceheader = entity.getContentEncoding();
                if (ceheader != null) {
                    HeaderElement[] codecs = ceheader.getElements();
                    for (int i = 0; i < codecs.length; i++) {
                        if (codecs[i].getName().equalsIgnoreCase("gzip")) {
                            response.setEntity(new GzipDecompressingEntity(response.getEntity()));
                            return;
                        }
                    }
                }
            }
        }
    };
}
项目:gradle-download-task    文件:InterceptorTest.java   
/**
 * Tests if we can manipulate a response
 * @throws Exception if anything goes wrong
 */
@Test
public void interceptResponse() throws Exception {
    final AtomicBoolean interceptorCalled = new AtomicBoolean(false);

    Download t = makeProjectAndTask();
    t.src(makeSrc(INTERCEPTOR));
    File dst = folder.newFile();
    t.dest(dst);
    t.responseInterceptor(new HttpResponseInterceptor() {
        @Override
        public void process(HttpResponse response, HttpContext context)
                throws HttpException, IOException {
            assertFalse(interceptorCalled.get());
            interceptorCalled.set(true);
            response.setEntity(new StringEntity(INTERCEPTED));
        }
    });
    t.execute();

    assertTrue(interceptorCalled.get());

    String dstContents = FileUtils.readFileToString(dst);
    assertEquals(INTERCEPTED, dstContents);
}
项目:selen-confetqa-2013    文件:Sample8_DownloadingFiles.java   
@Test
public void downloadingFiles() throws Exception {
  ProxyServer bmp = new ProxyServer(8071);
  bmp.start();

  HttpResponseInterceptor downloader = new FileDownloader()
      .addContentType("application/pdf");
  bmp.addResponseInterceptor(downloader);

  DesiredCapabilities caps = new DesiredCapabilities();
  caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());

  WebDriver driver = new FirefoxDriver(caps);

  driver.get("http://localhost/test_download.html");
  driver.findElement(By.tagName("a")).click();

  String fileName = driver.findElement(By.tagName("body")).getText();
  assertTrue(new File(fileName).exists());

  Thread.sleep(30000);

  driver.quit();

  bmp.stop();
}
项目:lams    文件:DecompressingHttpClient.java   
DecompressingHttpClient(HttpClient backend, 
        HttpRequestInterceptor requestInterceptor, 
        HttpResponseInterceptor responseInterceptor) {
    this.backend = backend;
    this.acceptEncodingInterceptor = requestInterceptor;
    this.contentEncodingInterceptor = responseInterceptor;
}
项目:lams    文件:BasicHttpProcessor.java   
public void addResponseInterceptor(
        final HttpResponseInterceptor itcp, int index) {
    if (itcp == null) {
        return;
    }
    this.responseInterceptors.add(index, itcp);
}
项目:lams    文件:BasicHttpProcessor.java   
public void removeResponseInterceptorByClass(final Class<? extends HttpResponseInterceptor> clazz) {
    for (Iterator<HttpResponseInterceptor> it = this.responseInterceptors.iterator();
         it.hasNext(); ) {
        Object request = it.next();
        if (request.getClass().equals(clazz)) {
            it.remove();
        }
    }
}
项目:lams    文件:BasicHttpProcessor.java   
public void process(
        final HttpResponse response,
        final HttpContext context)
        throws IOException, HttpException {
    for (int i = 0; i < this.responseInterceptors.size(); i++) {
        HttpResponseInterceptor interceptor =
            this.responseInterceptors.get(i);
        interceptor.process(response, context);
    }
}
项目:PhET    文件:ElementalHttpServer.java   
public RequestListenerThread(int port, final String docroot) throws IOException {
    this.serversocket = new ServerSocket(port);
    this.params = new SyncBasicHttpParams();
    this.params
        .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
        .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
        .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
        .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
        .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

    // Set up the HTTP protocol processor
    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
            new ResponseDate(),
            new ResponseServer(),
            new ResponseContent(),
            new ResponseConnControl()
    });

    // Set up request handlers
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpFileHandler(docroot));

    // Set up the HTTP service
    this.httpService = new HttpService(
            httpproc, 
            new DefaultConnectionReuseStrategy(), 
            new DefaultHttpResponseFactory(),
            reqistry,
            this.params);
}
项目:aerodrome-for-jet    文件:APIHttpClient.java   
/**
 * If gzip is enabled, this will decode things.
 * @return 
 */
private HttpResponseInterceptor createGzipResponseInterceptor()
{
  return new HttpResponseInterceptor() 
  {
    @Override
    public void process( HttpResponse response, HttpContext context ) 
      throws HttpException, IOException 
    {
      //..get the entity
      final HttpEntity entity = response.getEntity();
      if ( entity == null )
        return;

      //..Get any content encoding headers
      final Header ceHeader = entity.getContentEncoding();
      if ( ceHeader == null )
        return;

      //..Get any entries
      HeaderElement[] codecs = ceHeader.getElements();

      //..See if one is marked as gzip 
      for ( final HeaderElement codec : codecs ) 
      {
        if ( codec.getName().equalsIgnoreCase( "gzip" )) 
        {
          //..Hey, it's gzip! decompress the entity 
          response.setEntity( new GzipDecompressingEntity( response.getEntity()));

          //..Done with this ish.
          return;
        }
      }
    }
  };
}
项目:remote-files-sync    文件:ImmutableHttpProcessor.java   
public void process(
        final HttpResponse response,
        final HttpContext context) throws IOException, HttpException {
    for (final HttpResponseInterceptor responseInterceptor : this.responseInterceptors) {
        responseInterceptor.process(response, context);
    }
}
项目:remote-files-sync    文件:HttpProcessorBuilder.java   
public HttpProcessorBuilder addFirst(final HttpResponseInterceptor e) {
    if (e == null) {
        return this;
    }
    getResponseChainBuilder().addFirst(e);
    return this;
}
项目:remote-files-sync    文件:HttpProcessorBuilder.java   
public HttpProcessorBuilder addLast(final HttpResponseInterceptor e) {
    if (e == null) {
        return this;
    }
    getResponseChainBuilder().addLast(e);
    return this;
}
项目:remote-files-sync    文件:HttpProcessorBuilder.java   
public HttpProcessorBuilder addAllFirst(final HttpResponseInterceptor... e) {
    if (e == null) {
        return this;
    }
    getResponseChainBuilder().addAllFirst(e);
    return this;
}
项目:remote-files-sync    文件:HttpProcessorBuilder.java   
public HttpProcessorBuilder addAllLast(final HttpResponseInterceptor... e) {
    if (e == null) {
        return this;
    }
    getResponseChainBuilder().addAllLast(e);
    return this;
}
项目:remote-files-sync    文件:HttpClientBuilder.java   
/**
 * Adds this protocol interceptor to the head of the protocol processing list.
 * <p/>
 * Please note this value can be overridden by the {@link #setHttpProcessor(
 * org.apache.http.protocol.HttpProcessor)} method.
 */
public final HttpClientBuilder addInterceptorFirst(final HttpResponseInterceptor itcp) {
    if (itcp == null) {
        return this;
    }
    if (responseFirst == null) {
        responseFirst = new LinkedList<HttpResponseInterceptor>();
    }
    responseFirst.addFirst(itcp);
    return this;
}
项目:remote-files-sync    文件:HttpClientBuilder.java   
/**
 * Adds this protocol interceptor to the tail of the protocol processing list.
 * <p/>
 * Please note this value can be overridden by the {@link #setHttpProcessor(
 * org.apache.http.protocol.HttpProcessor)} method.
 */
public final HttpClientBuilder addInterceptorLast(final HttpResponseInterceptor itcp) {
    if (itcp == null) {
        return this;
    }
    if (responseLast == null) {
        responseLast = new LinkedList<HttpResponseInterceptor>();
    }
    responseLast.addLast(itcp);
    return this;
}
项目:wingtips    文件:WingtipsApacheHttpClientInterceptorTest.java   
@DataProvider(value = {
    "true",
    "false"
})
@Test
public void addTracingInterceptors_double_arg_works_as_expected(boolean subspanOptionOn) {
    // given
    HttpClientBuilder builder = HttpClientBuilder.create();

    // when
    addTracingInterceptors(builder, subspanOptionOn);

    // then
    HttpClientBuilderInterceptors builderInterceptors = new HttpClientBuilderInterceptors(builder);

    assertThat(builderInterceptors.firstRequestInterceptors).hasSize(1);
    assertThat(builderInterceptors.lastResponseInterceptors).hasSize(1);

    HttpRequestInterceptor requestInterceptor = builderInterceptors.firstRequestInterceptors.get(0);
    HttpResponseInterceptor responseInterceptor = builderInterceptors.lastResponseInterceptors.get(0);
    assertThat(requestInterceptor).isInstanceOf(WingtipsApacheHttpClientInterceptor.class);
    assertThat(responseInterceptor).isInstanceOf(WingtipsApacheHttpClientInterceptor.class);

    assertThat(((WingtipsApacheHttpClientInterceptor)requestInterceptor).surroundCallsWithSubspan)
        .isEqualTo(subspanOptionOn);
    assertThat(((WingtipsApacheHttpClientInterceptor)responseInterceptor).surroundCallsWithSubspan)
        .isEqualTo(subspanOptionOn);

    assertThat(builderInterceptors.lastRequestInterceptors).isNullOrEmpty();
    assertThat(builderInterceptors.firstResponseInterceptors).isNullOrEmpty();

    if (subspanOptionOn) {
        assertThat(builderInterceptors.firstRequestInterceptors).containsExactly(DEFAULT_REQUEST_IMPL);
        assertThat(builderInterceptors.lastResponseInterceptors).containsExactly(DEFAULT_RESPONSE_IMPL);
    }
}
项目:wingtips    文件:WingtipsApacheHttpClientInterceptorTest.java   
public HttpClientBuilderInterceptors(HttpClientBuilder builder) {
    this.firstRequestInterceptors =
        (List<HttpRequestInterceptor>) Whitebox.getInternalState(builder, "requestFirst");
    this.lastRequestInterceptors =
        (List<HttpRequestInterceptor>) Whitebox.getInternalState(builder, "requestLast");
    this.firstResponseInterceptors =
        (List<HttpResponseInterceptor>) Whitebox.getInternalState(builder, "responseFirst");
    this.lastResponseInterceptors =
        (List<HttpResponseInterceptor>) Whitebox.getInternalState(builder, "responseLast");
}
项目:java-binrepo-proxy    文件:ElementalReverseProxy.java   
public RequestListenerThread(final int port, final HttpHost target) throws IOException {
    this.target = target;
    this.serversocket = new ServerSocket(port);

    // Set up HTTP protocol processor for incoming connections
    final HttpProcessor inhttpproc = new ImmutableHttpProcessor(
            new HttpRequestInterceptor[] {
                    new RequestContent(),
                    new RequestTargetHost(),
                    new RequestConnControl(),
                    new RequestUserAgent("Test/1.1"),
                    new RequestExpectContinue(true)
     });

    // Set up HTTP protocol processor for outgoing connections
    final HttpProcessor outhttpproc = new ImmutableHttpProcessor(
            new HttpResponseInterceptor[] {
                    new ResponseDate(),
                    new ResponseServer("Test/1.1"),
                    new ResponseContent(),
                    new ResponseConnControl()
    });

    // Set up outgoing request executor
    final HttpRequestExecutor httpexecutor = new HttpRequestExecutor();

    // Set up incoming request handler
    final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
    reqistry.register("*", new ProxyHandler(
            this.target,
            outhttpproc,
            httpexecutor));

    // Set up the HTTP service
    this.httpService = new HttpService(inhttpproc, reqistry);
}
项目:java-binrepo-proxy    文件:HttpCoreTransportServer.java   
public RequestListenerThread(final int port, final HttpHost target, final TransportHandler handler) throws IOException {
    this.target = target;
    this.serversocket = new ServerSocket(port);

    // Set up HTTP protocol processor for incoming connections
    final HttpProcessor inhttpproc = new ImmutableHttpProcessor(
            new HttpRequestInterceptor[] {
                    new RequestContent(),
                    new RequestTargetHost(),
                    new RequestConnControl(),
                    new RequestUserAgent("Test/1.1"),
                    new RequestExpectContinue(true)
     });

    // Set up HTTP protocol processor for outgoing connections
    final HttpProcessor outhttpproc = new ImmutableHttpProcessor(
            new HttpResponseInterceptor[] {
                    new ResponseDate(),
                    new ResponseServer("Test/1.1"),
                    new ResponseContent(),
                    new ResponseConnControl()
    });

    // Set up outgoing request executor
    final HttpRequestExecutor httpexecutor = new HttpRequestExecutor();

    // Set up incoming request handler
    final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
    reqistry.register("*", new ProxyHandler(
            this.target,
            outhttpproc,
            httpexecutor,
            handler));

    // Set up the HTTP service
    this.httpService = new HttpService(inhttpproc, reqistry);
}
项目:Camel    文件:HttpTestServer.java   
/**
 * Obtains an HTTP protocol processor with default interceptors.
 *
 * @return  a protocol processor for server-side use
 */
protected HttpProcessor newProcessor() {
    return new ImmutableHttpProcessor(new HttpResponseInterceptor[] {new ResponseDate(),
                                                                     new ResponseServer(),
                                                                     new ResponseContent(),
                                                                     new ResponseConnControl()});
}
项目:Camel    文件:HttpCompressionTest.java   
@Override
protected HttpProcessor getBasicHttpProcessor() {
    List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
    requestInterceptors.add(new RequestDecompressingInterceptor());
    List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
    responseInterceptors.add(new ResponseCompressingInterceptor());
    responseInterceptors.add(new ResponseBasicUnauthorized());
    ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
    return httpproc;
}
项目:Camel    文件:HttpAuthenticationTest.java   
@Override
protected HttpProcessor getBasicHttpProcessor() {
    List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
    requestInterceptors.add(new RequestBasicAuth());
    List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
    responseInterceptors.add(new ResponseContent());
    responseInterceptors.add(new ResponseBasicUnauthorized());
    ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
    return httpproc;
}
项目:Camel    文件:HttpProxyServerTest.java   
@Override
protected HttpProcessor getBasicHttpProcessor() {
    List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
    requestInterceptors.add(new RequestProxyBasicAuth());
    List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
    responseInterceptors.add(new ResponseContent());
    responseInterceptors.add(new ResponseProxyBasicUnauthorized());
    ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
    return httpproc;
}
项目:Camel    文件:HttpsAuthenticationTest.java   
@Override
protected HttpProcessor getBasicHttpProcessor() {
    List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
    requestInterceptors.add(new RequestBasicAuth());
    List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
    responseInterceptors.add(new ResponseContent());
    responseInterceptors.add(new ResponseBasicUnauthorized());
    ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);

    return httpproc;
}
项目:purecloud-iot    文件:DecompressingHttpClient.java   
DecompressingHttpClient(final HttpClient backend,
        final HttpRequestInterceptor requestInterceptor,
        final HttpResponseInterceptor responseInterceptor) {
    this.backend = backend;
    this.acceptEncodingInterceptor = requestInterceptor;
    this.contentEncodingInterceptor = responseInterceptor;
}
项目:purecloud-iot    文件:HttpClientBuilder.java   
/**
 * Adds this protocol interceptor to the head of the protocol processing list.
 * <p>
 * Please note this value can be overridden by the {@link #setHttpProcessor(
 * org.apache.http.protocol.HttpProcessor)} method.
 * </p>
 */
public final HttpClientBuilder addInterceptorFirst(final HttpResponseInterceptor itcp) {
    if (itcp == null) {
        return this;
    }
    if (responseFirst == null) {
        responseFirst = new LinkedList<HttpResponseInterceptor>();
    }
    responseFirst.addFirst(itcp);
    return this;
}
项目:purecloud-iot    文件:HttpClientBuilder.java   
/**
 * Adds this protocol interceptor to the tail of the protocol processing list.
 * <p>
 * Please note this value can be overridden by the {@link #setHttpProcessor(
 * org.apache.http.protocol.HttpProcessor)} method.
 * </p>
 */
public final HttpClientBuilder addInterceptorLast(final HttpResponseInterceptor itcp) {
    if (itcp == null) {
        return this;
    }
    if (responseLast == null) {
        responseLast = new LinkedList<HttpResponseInterceptor>();
    }
    responseLast.addLast(itcp);
    return this;
}