Example usage for io.netty.handler.codec.http DefaultHttpRequest method

List of usage examples for io.netty.handler.codec.http DefaultHttpRequest method

Introduction

In this page you can find the example usage for io.netty.handler.codec.http DefaultHttpRequest method.

Prototype

HttpMethod method

To view the source code for io.netty.handler.codec.http DefaultHttpRequest method.

Click Source Link

Usage

From source file:io.vertx.core.http.impl.WebSocketRequestHandler.java

License:Open Source License

/**
 * Handle the request once we have the full body.
 *///  www.j a  v a  2 s  .  c  o  m
private void handle(HttpServerRequestImpl req, Buffer body) {
    DefaultHttpRequest nettyReq = req.getRequest();
    nettyReq = new DefaultFullHttpRequest(nettyReq.protocolVersion(), nettyReq.method(), nettyReq.uri(),
            body.getByteBuf(), nettyReq.headers(), EmptyHttpHeaders.INSTANCE);
    req.setRequest(nettyReq);
    ServerWebSocketImpl ws = ((Http1xServerConnection) req.connection()).createWebSocket(req);
    if (METRICS_ENABLED && metrics != null) {
        ws.setMetric(metrics.connected(((Http1xServerConnection) req.connection()).metric(), ws));
    }
    if (handlers.wsHandler != null) {
        handlers.wsHandler.handle(ws);
        if (!ws.isRejected()) {
            ws.connectNow();
        } else {
            req.response().setStatusCode(ws.getRejectedStatus().code()).end();
        }
    } else {
        handlers.requestHandler.handle(req);
    }
}