Search in sources :

Example 1 with HttpProcessorBuilder

use of org.apache.http.protocol.HttpProcessorBuilder in project LogHub by fbacchella.

the class HttpTestServer method before.

@Override
protected void before() throws Throwable {
    HttpProcessorBuilder builder = HttpProcessorBuilder.create().add(new ResponseDate()).add(new ResponseServer("MyServer-HTTP/1.1")).add(new ResponseContent()).add(new ResponseConnControl());
    HttpProcessor httpProcessor = builder.build();
    SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(15000).setTcpNoDelay(true).build();
    ServerBootstrap bootstrap = ServerBootstrap.bootstrap().setListenerPort(port).setHttpProcessor(httpProcessor).setSocketConfig(socketConfig);
    if (ssl != null) {
        bootstrap.setSslContext(ssl);
    }
    Arrays.stream(handlers).forEach(i -> bootstrap.registerHandler(i.getKey(), i.getValue()));
    server = bootstrap.create();
    server.start();
}
Also used : ResponseContent(org.apache.http.protocol.ResponseContent) HttpProcessorBuilder(org.apache.http.protocol.HttpProcessorBuilder) ResponseDate(org.apache.http.protocol.ResponseDate) SocketConfig(org.apache.http.config.SocketConfig) HttpProcessor(org.apache.http.protocol.HttpProcessor) ResponseConnControl(org.apache.http.protocol.ResponseConnControl) ServerBootstrap(org.apache.http.impl.bootstrap.ServerBootstrap) ResponseServer(org.apache.http.protocol.ResponseServer)

Aggregations

SocketConfig (org.apache.http.config.SocketConfig)1 ServerBootstrap (org.apache.http.impl.bootstrap.ServerBootstrap)1 HttpProcessor (org.apache.http.protocol.HttpProcessor)1 HttpProcessorBuilder (org.apache.http.protocol.HttpProcessorBuilder)1 ResponseConnControl (org.apache.http.protocol.ResponseConnControl)1 ResponseContent (org.apache.http.protocol.ResponseContent)1 ResponseDate (org.apache.http.protocol.ResponseDate)1 ResponseServer (org.apache.http.protocol.ResponseServer)1