org.apache.http.protocol.ImmutableHttpProcessor Java Examples

The following examples show how to use org.apache.http.protocol.ImmutableHttpProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestHttpServer.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: HttpConnectorVerifierTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static HttpProcessor getHttpProcessor() {
    return new ImmutableHttpProcessor(
        Arrays.asList(
            new RequestBasicAuth()
        ),
        Arrays.asList(
            new ResponseContent(),
            new ResponseBasicUnauthorized())
    );
}
 
Example #3
Source File: JsonRpcHttpAsyncClient.java    From jsonrpc4j with MIT License 5 votes vote down vote up
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());
}