use of org.apache.hc.core5.http.io.SocketConfig in project httpcomponents-core by apache.
the class TestingFramework method startServer.
private void startServer() throws TestingFrameworkException {
/*
* Start an in-process server and handle all HTTP requests
* with the requestHandler.
*/
final SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(15000, TimeUnit.MILLISECONDS).build();
final ServerBootstrap serverBootstrap = ServerBootstrap.bootstrap().setLookupRegistry(new UriPatternMatcher<>()).setSocketConfig(socketConfig).register("/*", requestHandler);
server = serverBootstrap.create();
try {
server.start();
} catch (final IOException e) {
throw new TestingFrameworkException(e);
}
port = server.getLocalPort();
}
use of org.apache.hc.core5.http.io.SocketConfig in project httpcomponents-core by apache.
the class ClassicTestClient method start.
public void start(final HttpProcessor httpProcessor) {
if (requesterRef.get() == null) {
final HttpRequestExecutor requestExecutor = new HttpRequestExecutor(HttpRequestExecutor.DEFAULT_WAIT_FOR_CONTINUE, DefaultConnectionReuseStrategy.INSTANCE, LoggingHttp1StreamListener.INSTANCE);
final StrictConnPool<HttpHost, HttpClientConnection> connPool = new StrictConnPool<>(20, 50, TimeValue.NEG_ONE_MILLISECOND, PoolReusePolicy.LIFO, LoggingConnPoolListener.INSTANCE);
final HttpRequester requester = new HttpRequester(requestExecutor, httpProcessor != null ? httpProcessor : HttpProcessors.client(), connPool, socketConfig, new LoggingBHttpClientConnectionFactory(Http1Config.DEFAULT, CharCodingConfig.DEFAULT), sslContext != null ? sslContext.getSocketFactory() : null, null, null, DefaultAddressResolver.INSTANCE);
requesterRef.compareAndSet(null, requester);
} else {
throw new IllegalStateException("Requester has already been started");
}
}
Aggregations