Java 类org.apache.http.protocol.HttpProcessor 实例源码

项目:JInsight    文件:RequestExecutorBasedClientInstrumentationTest.java   
public HttpResponse execute(HttpRequest request) throws IOException, HttpException {
  HttpParams params = new BasicHttpParams();
  HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);

  HttpProcessor processor = new ImmutableHttpProcessor(new RequestContent());

  HttpRequestExecutor executor = new HttpRequestExecutor();

  HttpContext context = new BasicHttpContext(null);
  context.setAttribute(ExecutionContext.HTTP_CONNECTION, connection);

  if (!connection.isOpen()) {
    Socket socket = new Socket(address.getAddress(), address.getPort());
    connection.bind(socket, params);
  }

  context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
  request.setParams(params);
  executor.preProcess(request, processor, context);
  HttpResponse response = executor.execute(request, connection, context);
  executor.postProcess(response, processor, context);

  return response;
}
项目:lams    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            new DefaultRedirectStrategyAdaptor(redirectHandler),
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:lams    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final Log log,
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            redirectStrategy,
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            new DefaultRedirectStrategyAdaptor(redirectHandler),
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:DefaultRequestDirector.java   
@Deprecated
public DefaultRequestDirector(
        final Log log,
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            redirectStrategy,
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:HttpClientBuilder.java   
/**
 * Produces an instance of {@link ClientExecChain} to be used as a main exec.
 * <p>
 * Default implementation produces an instance of {@link MainClientExec}
 * </p>
 * <p>
 * For internal use.
 * </p>
 *
 * @since 4.4
 */
protected ClientExecChain createMainExec(
        final HttpRequestExecutor requestExec,
        final HttpClientConnectionManager connManager,
        final ConnectionReuseStrategy reuseStrategy,
        final ConnectionKeepAliveStrategy keepAliveStrategy,
        final HttpProcessor proxyHttpProcessor,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler)
{
    return new MainClientExec(
            requestExec,
            connManager,
            reuseStrategy,
            keepAliveStrategy,
            proxyHttpProcessor,
            targetAuthStrategy,
            proxyAuthStrategy,
            userTokenHandler);
}
项目: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);
}
项目:gondola    文件:LocalTestServer.java   
public LocalTestServer(HttpRequestHandler handler) {
    try {
        setUp();
        HttpProcessor httpproc = HttpProcessorBuilder.create()
            .add(new ResponseDate())
            .add(new ResponseServer(LocalServerTestBase.ORIGIN))
            .add(new ResponseContent())
            .add(new ResponseConnControl())
            .add(new RequestBasicAuth())
            .add(new ResponseBasicUnauthorized()).build();
        this.serverBootstrap.setHttpProcessor(httpproc);
        this.serverBootstrap.registerHandler("*", handler);
        host = start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:Cherry    文件:WebEngine.java   
private HttpProcessor getHttpProcessor() {
  if (null == _httpProcessor) {
    final HttpProcessorBuilder httpProcessorBuilder = HttpProcessorBuilder.create();

    httpProcessorBuilder.add(new ResponseDate());
    httpProcessorBuilder.add(new ResponseServer(getOriginServer()));
    httpProcessorBuilder.add(new ResponseContent());
    httpProcessorBuilder.add(new ResponseConnControl());
    httpProcessorBuilder.add(getRequestInterceptorService());
    httpProcessorBuilder.add(getResponseInterceptorService());

    _httpProcessor = httpProcessorBuilder.build();
  }

  return _httpProcessor;
}
项目:nio-benchmark    文件:AsyncServer.java   
public void start() throws Exception {
    // Create HTTP protocol basic processing chain
    HttpProcessor httpProcessor = HttpProcessorBuilder.create()
            .add(new ResponseDate()).add(new ResponseContent())
            .add(new ResponseConnControl()).build();
    // Create server
    HttpAsyncService protocolHandler = new HttpAsyncService(httpProcessor,
            uriMapper);
    NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory = new DefaultNHttpServerConnectionFactory();
    IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(
            protocolHandler, connFactory);
    IOReactorConfig config = IOReactorConfig.custom()
            .setIoThreadCount(threads).setSoReuseAddress(true).build();
    ListeningIOReactor ioReactor = new DefaultListeningIOReactor(config);
    // Start server
    ioReactor.listen(new InetSocketAddress(port));
    ioReactor.execute(ioEventDispatch);
}
项目:SoundcloudAPI    文件:ApiWrapper.java   
/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */
protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec,
                                             ClientConnectionManager conman,
                                             ConnectionReuseStrategy reustrat,
                                             ConnectionKeepAliveStrategy kastrat,
                                             HttpRoutePlanner rouplan,
                                             HttpProcessor httpProcessor,
                                             HttpRequestRetryHandler retryHandler,
                                             RedirectHandler redirectHandler,
                                             AuthenticationHandler targetAuthHandler,
                                             AuthenticationHandler proxyAuthHandler,
                                             UserTokenHandler stateHandler,
                                             HttpParams params
) {
    return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan,
            httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler,
            stateHandler, params);
}
项目:wso2-axis2    文件:AxisHttpRequestImpl.java   
public AxisHttpRequestImpl(
        final AxisHttpConnection conn,
        final HttpRequest request, 
        final HttpProcessor httpproc,
        final HttpContext context) {
    super();
    if (conn == null) {
        throw new IllegalArgumentException("HTTP connection may not be null");
    }
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    if (httpproc == null) {
        throw new IllegalArgumentException("HTTP processor may not be null");
    }
    if (context == null) {
        throw new IllegalArgumentException("HTTP context may not be null");
    }
    this.request = request;
    this.conn = conn;
    this.httpproc = httpproc;
    this.context = context;
}
项目:wso2-axis2    文件:AxisHttpResponseImpl.java   
public AxisHttpResponseImpl(
        final AxisHttpConnection conn,
        final HttpResponse response, 
        final HttpProcessor httpproc,
        final HttpContext context) {
    super();
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    if (conn == null) {
        throw new IllegalArgumentException("HTTP connection may not be null");
    }
    if (httpproc == null) {
        throw new IllegalArgumentException("HTTP processor may not be null");
    }
    if (context == null) {
        throw new IllegalArgumentException("HTTP context may not be null");
    }
    this.response = response;
    this.conn = conn;
    this.httpproc = httpproc;
    this.context = context;
}
项目:paperchains    文件:ApiWrapper.java   
/** This method mainly exists to make the wrapper more testable. oh, apache's insanity. */
protected RequestDirector getRequestDirector(HttpRequestExecutor requestExec,
                                             ClientConnectionManager conman,
                                             ConnectionReuseStrategy reustrat,
                                             ConnectionKeepAliveStrategy kastrat,
                                             HttpRoutePlanner rouplan,
                                             HttpProcessor httpProcessor,
                                             HttpRequestRetryHandler retryHandler,
                                             RedirectHandler redirectHandler,
                                             AuthenticationHandler targetAuthHandler,
                                             AuthenticationHandler proxyAuthHandler,
                                             UserTokenHandler stateHandler,
                                             HttpParams params
) {
    return new DefaultRequestDirector(requestExec, conman, reustrat, kastrat, rouplan,
            httpProcessor, retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler,
            stateHandler, params);
}
项目:haogrgr-test    文件:HttpSrvMain.java   
public static void main(String[] args) throws Exception {
    int port = 8080;
    String docRoot = "D:\\svn_file\\TEST2\\150503\\web-customer";

    // Set up the HTTP protocol processor
    HttpProcessor httpproc = HttpProcessorBuilder.create().add(new ResponseDate())
            .add(new ResponseServer("Haogrgr/1.1")).add(new ResponseContent())
            .add(new ResponseConnControl()).build();

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

    // Set up the HTTP service
    HttpService httpService = new HttpService(httpproc, reqistry);

    Thread t = new RequestListenerThread(port, httpService, null);
    t.setDaemon(false);
    t.start();
}
项目: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;
}
项目:CadalWorkspace    文件:Httpd.java   
public RequestListenerThread(int port, final String docroot) throws IOException {
    this.serversocket = new ServerSocket(port);
    this.params = new BasicHttpParams();
    this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 1000).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 BasicHttpProcessor();

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

    // Set up the HTTP service
    this.httpService = new HttpService(httpproc, new NoConnectionReuseStrategy(), new DefaultHttpResponseFactory());
    this.httpService.setParams(this.params);
    this.httpService.setHandlerResolver(reqistry);
}
项目:CadalWorkspace    文件:Httpd.java   
public RequestListenerThread(int port, final String docroot) throws IOException {
    this.serversocket = new ServerSocket(port);
    this.params = new BasicHttpParams();
    this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 1000).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 BasicHttpProcessor();

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

    // Set up the HTTP service
    this.httpService = new HttpService(httpproc, new NoConnectionReuseStrategy(), new DefaultHttpResponseFactory());
    this.httpService.setParams(this.params);
    this.httpService.setHandlerResolver(reqistry);
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.2) do not use
 */
@Deprecated 
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
项目:lams    文件:AbstractHttpClient.java   
/**
 * @since 4.2
 */
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthStrategy,
            proxyAuthStrategy,
            userTokenHandler,
            params);
}
项目:yaacc-code    文件:YaaccHttpService.java   
public YaaccHttpService(HttpProcessor proc,
                        ConnectionReuseStrategy connStrategy,
                        HttpResponseFactory responseFactory, Context context) {
    super(proc, connStrategy, responseFactory);
    this.context = context;

}
项目:outcomes    文件:TestHttpCore.java   
@Test
public void test() throws ExecutionException, InterruptedException {


    HttpHost target = new HttpHost("localhost");
    BasicConnPool connpool = new BasicConnPool();
    connpool.setMaxTotal(200);
    connpool.setDefaultMaxPerRoute(10);
    connpool.setMaxPerRoute(target, 20);
    Future<BasicPoolEntry> future = connpool.lease(target, null);
    BasicPoolEntry poolEntry = future.get();
    HttpClientConnection conn = poolEntry.getConnection();

    HttpProcessor httpproc = HttpProcessorBuilder.create()
            .add(new ResponseDate())
            .add(new ResponseServer("MyServer-HTTP/1.1"))
            .add(new ResponseContent())
            .add(new ResponseConnControl())
            .build();

    HttpRequestHandler myRequestHandler = new HttpRequestHandler() {

        public void handle(
                HttpRequest request,
                HttpResponse response,
                HttpContext context) throws HttpException, IOException {
            response.setStatusCode(HttpStatus.SC_OK);
            response.setEntity(
                    new StringEntity("some important message",
                            ContentType.TEXT_PLAIN));
        }

    };

    UriHttpRequestHandlerMapper handlerMapper = new UriHttpRequestHandlerMapper();
    handlerMapper.register("/service/*", myRequestHandler);
    HttpService httpService = new HttpService(httpproc, handlerMapper);
}
项目: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);
}
项目:PhET    文件:ElementalReverseProxy.java   
public ProxyHandler(
        final HttpHost target,
        final HttpProcessor httpproc,
        final HttpRequestExecutor httpexecutor) {
    super();
    this.target = target;
    this.httpproc = httpproc;
    this.httpexecutor = httpexecutor;
    this.connStrategy = new DefaultConnectionReuseStrategy();
}
项目:PhET    文件:NHttpReverseProxy.java   
public ListeningHandler(
        final HttpHost targetHost,
        final ConnectingIOReactor connectingIOReactor,
        final HttpProcessor httpProcessor, 
        final HttpResponseFactory responseFactory,
        final ConnectionReuseStrategy connStrategy,
        final HttpParams params) {
    super();
    this.targetHost = targetHost;
    this.connectingIOReactor = connectingIOReactor;
    this.httpProcessor = httpProcessor;
    this.connStrategy = connStrategy;
    this.responseFactory = responseFactory;
    this.params = params;
}
项目:PhET    文件:NHttpReverseProxy.java   
public ConnectingHandler(
        final HttpProcessor httpProcessor, 
        final ConnectionReuseStrategy connStrategy,
        final HttpParams params) {
    super();
    this.httpProcessor = httpProcessor;
    this.connStrategy = connStrategy;
    this.params = params;
}
项目:java-binrepo-proxy    文件:ElementalReverseProxy.java   
public ProxyHandler(
        final HttpHost target,
        final HttpProcessor httpproc,
        final HttpRequestExecutor httpexecutor) {
    super();
    this.target = target;
    this.httpproc = httpproc;
    this.httpexecutor = httpexecutor;
    this.connStrategy = DefaultConnectionReuseStrategy.INSTANCE;
}
项目: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);
}
项目:java-binrepo-proxy    文件:HttpCoreTransportServer.java   
public ProxyHandler(
        final HttpHost target,
        final HttpProcessor httpproc,
        final HttpRequestExecutor httpexecutor,
        final TransportHandler handler) {
    super();
    this.target = target;
    this.httpproc = httpproc;
    this.httpexecutor = httpexecutor;
    this.connStrategy = DefaultConnectionReuseStrategy.INSTANCE;
    this.handler = handler;
}
项目:java-binrepo-proxy    文件:HttpCoreTransportClientImpl.java   
public HttpCoreTransportClientImpl(HttpRequestExecutor httpexecutor, HttpProcessor httpproc, ConnectionReuseStrategy connStrategy, final HttpClientConnection conn, final HttpRequest request,
            final HttpResponse response,
            final HttpContext context) {
    this.httpexecutor = httpexecutor;
    this.httpproc = httpproc;
    this.connStrategy = connStrategy;
    this.conn = conn;
    this.request = request;
    this.response = response;
    this.context = context;
}
项目:java-binrepo-proxy    文件:HttpCoreTransportClientImpl.java   
@Override
public TransportFetch httpGetOtherFile(String uri) {
    HttpProcessor httpproc = HttpProcessorBuilder.create()
    .add(new RequestContent())
    .add(new RequestTargetHost())
    .add(new RequestConnControl())
    .add(new RequestUserAgent("Test/1.1"))
    .add(new RequestExpectContinue(true)).build();

    try {
        HttpRequest ascRequest = new BasicHttpRequest("GET", uri);
        LOG.info("Will fetch {}", ascRequest.getRequestLine());
        httpexecutor.preProcess(ascRequest, httpproc, context);
        final HttpResponse otherResponse = httpexecutor.execute(ascRequest, conn, context);
        httpexecutor.postProcess(response, httpproc, context);

        final byte[] otherBody = EntityUtils.toByteArray(otherResponse.getEntity());
        LOG.info("Read body of {} bytes", otherBody.length, " bytes");
        EntityUtils.consume(otherResponse.getEntity());

        boolean keepalive = connStrategy.keepAlive(response, context);
        context.setAttribute(HTTP_CONN_KEEPALIVE, new Boolean(keepalive));

        return new TransportFetch(otherResponse.getStatusLine().getStatusCode(), otherResponse.getStatusLine().getReasonPhrase(), otherBody);
    } catch (HttpException | IOException ex) {
        return new TransportFetch(500, ex.getLocalizedMessage(), null);
    }
}
项目: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    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.1) do not use
 */
@Deprecated
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
项目:purecloud-iot    文件:AbstractHttpClient.java   
/**
 * @deprecated (4.2) do not use
 */
@Deprecated
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}