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

下面列出了怎么用org.apache.http.protocol.HttpProcessor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: google-http-java-client   文件: MockHttpClient.java
@Override
protected RequestDirector createClientRequestDirector(
    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 RequestDirector() {
    @Beta
    public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
        throws HttpException, IOException {
      return new BasicHttpResponse(HttpVersion.HTTP_1_1, responseCode, null);
    }
  };
}
 
源代码2 项目: brooklyn-server   文件: TestHttpServer.java
public TestHttpServer start() {
    checkNotStarted();

    HttpProcessor httpProcessor = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
    int port = Networking.nextAvailablePort(basePort);
    ServerBootstrap bootstrap = ServerBootstrap.bootstrap()
        .setListenerPort(port)
        .setLocalAddress(getLocalAddress())
        .setHttpProcessor(httpProcessor);

    for (HandlerTuple tuple : handlers) {
        bootstrap.registerHandler(tuple.path, tuple.handler);
    }
    server = bootstrap.create();

    try {
        server.start();
    } catch (IOException e) {
        throw Exceptions.propagate(e);
    }

    return this;
}
 
源代码3 项目: syndesis   文件: HttpConnectorVerifierTest.java
private static HttpProcessor getHttpProcessor() {
    return new ImmutableHttpProcessor(
        Arrays.asList(
            new RequestBasicAuth()
        ),
        Arrays.asList(
            new ResponseContent(),
            new ResponseBasicUnauthorized())
    );
}
 
源代码4 项目: openxds   文件: IheHttpFactory.java
public HttpProcessor newHttpProcessor() {
    BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
    httpProcessor.addInterceptor(new RequestSessionCookie());
    httpProcessor.addInterceptor(new ResponseDate());
    httpProcessor.addInterceptor(new ResponseServer());
    httpProcessor.addInterceptor(new ResponseContent());
    httpProcessor.addInterceptor(new ResponseConnControl());
    httpProcessor.addInterceptor(new ResponseSessionCookie());
    return httpProcessor;
}
 
源代码5 项目: YiBo   文件: LibHttpClient.java
@Override
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 stateHandler,
        final HttpParams params) {
    return new LibRequestDirector(
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectHandler,
            targetAuthHandler,
            proxyAuthHandler,
            stateHandler,
            params);
}
 
源代码6 项目: jsonrpc4j   文件: JsonRpcHttpAsyncClient.java
private void initialize() {
	if (initialized.getAndSet(true)) {
		return;
	}
	IOReactorConfig.Builder config = createConfig();
	// params.setParameter(CoreProtocolPNames.USER_AGENT, "jsonrpc4j/1.0");
	final ConnectingIOReactor ioReactor = createIoReactor(config);
	createSslContext();
	int socketBufferSize = Integer.getInteger("com.googlecode.jsonrpc4j.async.socket.buffer", 8 * 1024);
	final ConnectionConfig connectionConfig = ConnectionConfig.custom().setBufferSize(socketBufferSize).build();
	BasicNIOConnFactory nioConnFactory = new BasicNIOConnFactory(sslContext, null, connectionConfig);
	pool = new BasicNIOConnPool(ioReactor, nioConnFactory, Integer.getInteger("com.googlecode.jsonrpc4j.async.connect.timeout", 30000));
	pool.setDefaultMaxPerRoute(Integer.getInteger("com.googlecode.jsonrpc4j.async.max.inflight.route", 500));
	pool.setMaxTotal(Integer.getInteger("com.googlecode.jsonrpc4j.async.max.inflight.total", 500));
	
	Thread t = new Thread(new Runnable() {
		@Override
		public void run() {
			try {
				HttpAsyncRequestExecutor protocolHandler = new HttpAsyncRequestExecutor();
				IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch(protocolHandler, sslContext, connectionConfig);
				ioReactor.execute(ioEventDispatch);
			} catch (InterruptedIOException ex) {
				System.err.println("Interrupted");
			} catch (IOException e) {
				System.err.println("I/O error: " + e.getMessage());
			}
		}
	}, "jsonrpc4j HTTP IOReactor");
	
	t.setDaemon(true);
	t.start();
	
	HttpProcessor httpProcessor = new ImmutableHttpProcessor(new RequestContent(), new RequestTargetHost(), new RequestConnControl(), new RequestUserAgent(), new RequestExpectContinue(false));
	requester = new HttpAsyncRequester(httpProcessor, new DefaultConnectionReuseStrategy());
}
 
public UpnpHttpService(HttpProcessor processor, ConnectionReuseStrategy reuse, HttpResponseFactory responseFactory) {
    super(processor, reuse, responseFactory);
}
 
public UpnpHttpService(HttpProcessor processor, ConnectionReuseStrategy reuse, HttpResponseFactory responseFactory) {
    super(processor, reuse, responseFactory);
}
 
源代码9 项目: YiBo   文件: LibRequestDirector.java
public LibRequestDirector(
        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) {

    if (requestExec == null) {
        throw new IllegalArgumentException("Request executor may not be null.");
    }
    if (conman == null) {
        throw new IllegalArgumentException("Client connection manager may not be null.");
    }
    if (reustrat == null) {
        throw new IllegalArgumentException("Connection reuse strategy may not be null.");
    }
    if (kastrat == null) {
        throw new IllegalArgumentException("Connection keep alive strategy may not be null.");
    }
    if (rouplan == null) {
        throw new IllegalArgumentException("Route planner may not be null.");
    }
    if (httpProcessor == null) {
        throw new IllegalArgumentException("HTTP protocol processor may not be null.");
    }
    if (retryHandler == null) {
        throw new IllegalArgumentException("HTTP request retry handler may not be null.");
    }
    if (redirectHandler == null) {
        throw new IllegalArgumentException("Redirect handler may not be null.");
    }
    if (targetAuthHandler == null) {
        throw new IllegalArgumentException("Target authentication handler may not be null.");
    }
    if (proxyAuthHandler == null) {
        throw new IllegalArgumentException("Proxy authentication handler may not be null.");
    }
    if (userTokenHandler == null) {
        throw new IllegalArgumentException("User token handler may not be null.");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.requestExec       = requestExec;
    this.connManager       = conman;
    this.reuseStrategy     = reustrat;
    this.keepAliveStrategy = kastrat;
    this.routePlanner      = rouplan;
    this.httpProcessor     = httpProcessor;
    this.retryHandler      = retryHandler;
    this.redirectHandler   = redirectHandler;
    this.targetAuthHandler = targetAuthHandler;
    this.proxyAuthHandler  = proxyAuthHandler;
    this.userTokenHandler  = userTokenHandler;
    this.params            = params;

    this.managedConn       = null;

    this.execCount = 0;
    this.redirectCount = 0;
    this.maxRedirects = this.params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
    this.targetAuthState = new AuthState();
    this.proxyAuthState = new AuthState();
}
 
 类所在包
 同包方法