Search in sources :

Example 1 with ServerBootstrap

use of org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap 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();
}
Also used : SocketConfig(org.apache.hc.core5.http.io.SocketConfig) IOException(java.io.IOException) ServerBootstrap(org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap)

Aggregations

IOException (java.io.IOException)1 ServerBootstrap (org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap)1 SocketConfig (org.apache.hc.core5.http.io.SocketConfig)1