Example usage for org.apache.http.impl.bootstrap ServerBootstrap create

List of usage examples for org.apache.http.impl.bootstrap ServerBootstrap create

Introduction

In this page you can find the example usage for org.apache.http.impl.bootstrap ServerBootstrap create.

Prototype

public HttpServer create() 

Source Link

Usage

From source file:com.adobe.ags.curly.test.TestWebServer.java

private TestWebServer(int port) throws IOException, InterruptedException {
    this.port = port;
    ServerBootstrap bootstrap = ServerBootstrap.bootstrap();
    bootstrap.setListenerPort(port);//  w w  w . j  a va  2s.  c  o  m
    bootstrap.setServerInfo("Test/1.1");
    bootstrap.setSocketConfig(SocketConfig.DEFAULT);
    bootstrap.registerHandler("*", this::handleHttpRequest);
    server = bootstrap.create();
    server.start();
}

From source file:brooklyn.test.TestHttpServer.java

public TestHttpServer start() {
    checkNotStarted();/*w ww  .jav a  2s.c o  m*/

    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;
}