Package org.webbitserver

Examples of org.webbitserver.HttpControl


    private void handleHttpRequest(ChannelHandlerContext ctx, MessageEvent messageEvent, HttpRequest httpRequest) {
        final NettyHttpRequest nettyHttpRequest = new NettyHttpRequest(messageEvent, httpRequest, id, timestamp);
        final NettyHttpResponse nettyHttpResponse = new NettyHttpResponse(
                ctx, new DefaultHttpResponse(HTTP_1_1, OK), exceptionHandler, ioExceptionHandler);
        final HttpControl control = new NettyHttpControl(httpHandlers.iterator(), executor, ctx,
                nettyHttpRequest, nettyHttpResponse, httpRequest, new DefaultHttpResponse(HTTP_1_1, OK),
                exceptionHandler, ioExceptionHandler);

        executor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    control.nextHandler(nettyHttpRequest, nettyHttpResponse);
                } catch (Exception exception) {
                    exceptionHandler.uncaughtException(Thread.currentThread(), exception);
                }
            }
        });
View Full Code Here


        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("http://host.com:8080/hello");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();

        pmh.handleHttpRequest(req, res, ctl);
        verify(handler).handleHttpRequest(req, res, ctl);
    }
View Full Code Here

        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("/hello");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();

        pmh.handleHttpRequest(req, res, ctl);
        verify(handler).handleHttpRequest(req, res, ctl);
    }
View Full Code Here

        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("http://hello.com:8080/wtf");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = mock(HttpControl.class);

        pmh.handleHttpRequest(req, res, ctl);

        verifyZeroInteractions(handler);
        verify(ctl).nextHandler();
View Full Code Here

        final NettyHttpRequest nettyHttpRequest = new NettyHttpRequest(messageEvent, httpRequest, id, timestamp);
        DefaultHttpResponse ok_200 = new DefaultHttpResponse(HTTP_1_1, OK);
        final NettyHttpResponse nettyHttpResponse = new NettyHttpResponse(
                ctx, ok_200, isKeepAlive(httpRequest), exceptionHandler);
        Iterator<HttpHandler> httpHandlers = this.httpHandlers.iterator();
        final HttpControl control = new NettyHttpControl(httpHandlers, executor, ctx,
                nettyHttpRequest, nettyHttpResponse, httpRequest, ok_200,
                exceptionHandler, ioExceptionHandler);

        executor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    control.nextHandler(nettyHttpRequest, nettyHttpResponse);
                } catch (Exception exception) {
                    exceptionHandler.uncaughtException(Thread.currentThread(), WebbitException.fromException(exception, ctx.getChannel()));
                }
            }
        });
View Full Code Here

        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("http://host.com:8080/hello");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();

        pmh.handleHttpRequest(req, res, ctl);
        verify(handler).handleHttpRequest(req, res, ctl);
    }
View Full Code Here

        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("/hello");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();

        pmh.handleHttpRequest(req, res, ctl);
        verify(handler).handleHttpRequest(req, res, ctl);
    }
View Full Code Here

        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello/.*", handler);

        HttpRequest req = new StubHttpRequest("/hello/world");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();

        pmh.handleHttpRequest(req, res, ctl);
        verify(handler).handleHttpRequest(req, res, ctl);
    }
View Full Code Here

        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("//");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = mock(HttpControl.class);

        pmh.handleHttpRequest(req, res, ctl);

        verifyZeroInteractions(handler);
        verify(ctl).nextHandler();
View Full Code Here

        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("http://hello.com:8080/wtf");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = mock(HttpControl.class);

        pmh.handleHttpRequest(req, res, ctl);

        verifyZeroInteractions(handler);
        verify(ctl).nextHandler();
View Full Code Here

TOP

Related Classes of org.webbitserver.HttpControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.