Home / Function/ handleHttpRequest() — netty Function Reference

handleHttpRequest() — netty Function Reference

Architecture documentation for the handleHttpRequest() function in WebSocketServerHandler.java from the netty codebase.

Function java Buffer Telemetry calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  fcec6aed_39e7_3b17_aeb4_b612a777c609["handleHttpRequest()"]
  3f7d4c4e_8262_9dae_1834_1af8d0f2e6dd["WebSocketServerHandler"]
  fcec6aed_39e7_3b17_aeb4_b612a777c609 -->|defined in| 3f7d4c4e_8262_9dae_1834_1af8d0f2e6dd
  75e316aa_b744_349b_a240_9ef9a100569e["channelRead0()"]
  75e316aa_b744_349b_a240_9ef9a100569e -->|calls| fcec6aed_39e7_3b17_aeb4_b612a777c609
  e1c780b8_8a58_a843_981f_2378e8000b08["sendHttpResponse()"]
  fcec6aed_39e7_3b17_aeb4_b612a777c609 -->|calls| e1c780b8_8a58_a843_981f_2378e8000b08
  style fcec6aed_39e7_3b17_aeb4_b612a777c609 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/http/websocketx/benchmarkserver/WebSocketServerHandler.java lines 65–108

    private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) {
        // Handle a bad request.
        if (!req.decoderResult().isSuccess()) {
            sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), BAD_REQUEST,
                                                                   ctx.alloc().buffer(0)));
            return;
        }

        // Allow only GET methods.
        if (!GET.equals(req.method())) {
            sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), FORBIDDEN,
                                                                   ctx.alloc().buffer(0)));
            return;
        }

        // Send the demo page and favicon.ico
        if ("/".equals(req.uri())) {
            ByteBuf content = WebSocketServerBenchmarkPage.getContent(getWebSocketLocation(req));
            FullHttpResponse res = new DefaultFullHttpResponse(req.protocolVersion(), OK, content);

            res.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html; charset=UTF-8");
            HttpUtil.setContentLength(res, content.readableBytes());

            sendHttpResponse(ctx, req, res);
            return;
        }

        if ("/favicon.ico".equals(req.uri())) {
            FullHttpResponse res = new DefaultFullHttpResponse(req.protocolVersion(), NOT_FOUND,
                                                               ctx.alloc().buffer(0));
            sendHttpResponse(ctx, req, res);
            return;
        }

        // Handshake
        WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
                getWebSocketLocation(req), null, true, 5 * 1024 * 1024);
        handshaker = wsFactory.newHandshaker(req);
        if (handshaker == null) {
            WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
        } else {
            handshaker.handshake(ctx.channel(), req);
        }
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does handleHttpRequest() do?
handleHttpRequest() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/http/websocketx/benchmarkserver/WebSocketServerHandler.java.
Where is handleHttpRequest() defined?
handleHttpRequest() is defined in example/src/main/java/io/netty/example/http/websocketx/benchmarkserver/WebSocketServerHandler.java at line 65.
What does handleHttpRequest() call?
handleHttpRequest() calls 1 function(s): sendHttpResponse.
What calls handleHttpRequest()?
handleHttpRequest() is called by 1 function(s): channelRead0.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free