Home / Function/ write() — netty Function Reference

write() — netty Function Reference

Architecture documentation for the write() function in HttpClientUpgradeHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  0b797072_8c60_5c0c_6331_82c13a807225["write()"]
  4e189e6a_8380_a786_56f2_e292de03b066["HttpClientUpgradeHandler"]
  0b797072_8c60_5c0c_6331_82c13a807225 -->|defined in| 4e189e6a_8380_a786_56f2_e292de03b066
  c78849c0_cacb_3aed_443a_6aef070c0943["setUpgradeRequestHeaders()"]
  0b797072_8c60_5c0c_6331_82c13a807225 -->|calls| c78849c0_cacb_3aed_443a_6aef070c0943
  style 0b797072_8c60_5c0c_6331_82c13a807225 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java lines 155–180

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
            throws Exception {
        if (!(msg instanceof HttpRequest) || currentUpgradeEvent == UpgradeEvent.UPGRADE_SUCCESSFUL) {
            ctx.write(msg, promise);
            return;
        }

        if (currentUpgradeEvent == UpgradeEvent.UPGRADE_ISSUED) {
            // Release message before failing the promise.
            ReferenceCountUtil.release(msg);
            promise.setFailure(new IllegalStateException(
                    "Attempting to write HTTP request with upgrade in progress"));
            return;
        }

        currentUpgradeEvent = UpgradeEvent.UPGRADE_ISSUED;
        setUpgradeRequestHeaders(ctx, (HttpRequest) msg);

        // Continue writing the request.
        ctx.write(msg, promise);

        // Notify that the upgrade request was issued.
        ctx.fireUserEventTriggered(UpgradeEvent.UPGRADE_ISSUED);
        // Now we wait for the next HTTP response to see if we switch protocols.
    }

Subdomains

Frequently Asked Questions

What does write() do?
write() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java.
Where is write() defined?
write() is defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java at line 155.
What does write() call?
write() calls 1 function(s): setUpgradeRequestHeaders.

Analyze Your Own Codebase

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

Try Supermodel Free