use of org.apache.hc.core5.function.Decorator in project httpcomponents-core by apache.
the class ClassicTestServer method start.
public void start(final Http1Config http1Config, final HttpProcessor httpProcessor, final Decorator<HttpServerRequestHandler> handlerDecorator) throws IOException {
if (serverRef.get() == null) {
final HttpServerRequestHandler handler = new BasicHttpServerRequestHandler(registry);
final HttpService httpService = new HttpService(httpProcessor != null ? httpProcessor : HttpProcessors.server(), handlerDecorator != null ? handlerDecorator.decorate(handler) : new BasicHttpServerExpectationDecorator(handler), DefaultConnectionReuseStrategy.INSTANCE, LoggingHttp1StreamListener.INSTANCE);
final HttpServer server = new HttpServer(0, httpService, null, socketConfig, sslContext != null ? sslContext.getServerSocketFactory() : ServerSocketFactory.getDefault(), new LoggingBHttpServerConnectionFactory(sslContext != null ? URIScheme.HTTPS.id : URIScheme.HTTP.id, http1Config != null ? http1Config : Http1Config.DEFAULT, CharCodingConfig.DEFAULT), null, LoggingExceptionListener.INSTANCE);
if (serverRef.compareAndSet(null, server)) {
server.start();
}
} else {
throw new IllegalStateException("Server already running");
}
}
use of org.apache.hc.core5.function.Decorator in project httpcomponents-core by apache.
the class H2TestServer method start.
public InetSocketAddress start(final HttpProcessor httpProcessor, final Decorator<AsyncServerExchangeHandler> exchangeHandlerDecorator, final H2Config h2Config) throws Exception {
start(new InternalServerProtocolNegotiationStarter(httpProcessor != null ? httpProcessor : H2Processors.server(), new DefaultAsyncResponseExchangeHandlerFactory(registry, exchangeHandlerDecorator != null ? exchangeHandlerDecorator : BasicAsyncServerExpectationDecorator::new), HttpVersionPolicy.FORCE_HTTP_2, h2Config, Http1Config.DEFAULT, CharCodingConfig.DEFAULT, sslContext, sslSessionInitializer, sslSessionVerifier));
final Future<ListenerEndpoint> future = listen(new InetSocketAddress(0));
final ListenerEndpoint listener = future.get();
return (InetSocketAddress) listener.getAddress();
}
use of org.apache.hc.core5.function.Decorator in project httpcomponents-core by apache.
the class H2TestServer method start.
public InetSocketAddress start(final HttpProcessor httpProcessor, final Decorator<AsyncServerExchangeHandler> exchangeHandlerDecorator, final Http1Config http1Config) throws Exception {
start(new InternalServerProtocolNegotiationStarter(httpProcessor != null ? httpProcessor : HttpProcessors.server(), new DefaultAsyncResponseExchangeHandlerFactory(registry, exchangeHandlerDecorator != null ? exchangeHandlerDecorator : BasicAsyncServerExpectationDecorator::new), HttpVersionPolicy.FORCE_HTTP_1, H2Config.DEFAULT, http1Config, CharCodingConfig.DEFAULT, sslContext, sslSessionInitializer, sslSessionVerifier));
final Future<ListenerEndpoint> future = listen(new InetSocketAddress(0));
final ListenerEndpoint listener = future.get();
return (InetSocketAddress) listener.getAddress();
}
Aggregations