Home / Class/ HttpClientUpgradeHandler Class — netty Architecture

HttpClientUpgradeHandler Class — netty Architecture

Architecture documentation for the HttpClientUpgradeHandler class in HttpClientUpgradeHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  4e189e6a_8380_a786_56f2_e292de03b066["HttpClientUpgradeHandler"]
  ce099943_c46d_ed39_bb85_d07243f07181["HttpClientUpgradeHandler.java"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|defined in| ce099943_c46d_ed39_bb85_d07243f07181
  e9577a06_b9c3_4b83_13bf_bd47625984d7["HttpClientUpgradeHandler()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| e9577a06_b9c3_4b83_13bf_bd47625984d7
  becf4051_a2f2_4bf0_ed93_731cc01d0fb0["bind()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| becf4051_a2f2_4bf0_ed93_731cc01d0fb0
  a94822dc_1672_1e0f_d445_a9a96582c79c["connect()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| a94822dc_1672_1e0f_d445_a9a96582c79c
  93065856_2628_6ea0_54c3_1eeb0f94e0a3["disconnect()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| 93065856_2628_6ea0_54c3_1eeb0f94e0a3
  a5386655_5354_88db_5967_f7f8ba14d7df["close()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| a5386655_5354_88db_5967_f7f8ba14d7df
  0fc5fddd_b18e_dbad_aa65_99f7142596df["deregister()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| 0fc5fddd_b18e_dbad_aa65_99f7142596df
  3c2d04d9_111f_429e_b149_8f07664aa821["read()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| 3c2d04d9_111f_429e_b149_8f07664aa821
  0b797072_8c60_5c0c_6331_82c13a807225["write()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| 0b797072_8c60_5c0c_6331_82c13a807225
  d8e9ba9b_ac46_9864_a0c2_1ff3481530df["flush()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| d8e9ba9b_ac46_9864_a0c2_1ff3481530df
  9d58037d_586e_ddf3_d949_447c40752f74["decode()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| 9d58037d_586e_ddf3_d949_447c40752f74
  68cbc489_4c93_02e4_be2a_4026606c980c["removeThisHandler()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| 68cbc489_4c93_02e4_be2a_4026606c980c
  c78849c0_cacb_3aed_443a_6aef070c0943["setUpgradeRequestHeaders()"]
  4e189e6a_8380_a786_56f2_e292de03b066 -->|method| c78849c0_cacb_3aed_443a_6aef070c0943

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java lines 40–284

public class HttpClientUpgradeHandler extends HttpObjectAggregator implements ChannelOutboundHandler {

    /**
     * User events that are fired to notify about upgrade status.
     */
    public enum UpgradeEvent {
        /**
         * The Upgrade request was sent to the server.
         */
        UPGRADE_ISSUED,

        /**
         * The Upgrade to the new protocol was successful.
         */
        UPGRADE_SUCCESSFUL,

        /**
         * The Upgrade was unsuccessful due to the server not issuing
         * with a 101 Switching Protocols response.
         */
        UPGRADE_REJECTED
    }

    /**
     * The source codec that is used in the pipeline initially.
     */
    public interface SourceCodec {

        /**
         * Removes or disables the encoder of this codec so that the {@link UpgradeCodec} can send an initial greeting
         * (if any).
         */
        void prepareUpgradeFrom(ChannelHandlerContext ctx);

        /**
         * Removes this codec (i.e. all associated handlers) from the pipeline.
         */
        void upgradeFrom(ChannelHandlerContext ctx);
    }

    /**
     * A codec that the source can be upgraded to.
     */
    public interface UpgradeCodec {
        /**
         * Returns the name of the protocol supported by this codec, as indicated by the {@code 'UPGRADE'} header.
         */
        CharSequence protocol();

        /**
         * Sets any protocol-specific headers required to the upgrade request. Returns the names of
         * all headers that were added. These headers will be used to populate the CONNECTION header.
         */
        Collection<CharSequence> setUpgradeHeaders(ChannelHandlerContext ctx, HttpRequest upgradeRequest);

        /**
         * Performs an HTTP protocol upgrade from the source codec. This method is responsible for
         * adding all handlers required for the new protocol.
         *
         * @param ctx the context for the current handler.
         * @param upgradeResponse the 101 Switching Protocols response that indicates that the server
         *            has switched to this protocol.
         */
        void upgradeTo(ChannelHandlerContext ctx, FullHttpResponse upgradeResponse) throws Exception;
    }

    private final SourceCodec sourceCodec;
    private final UpgradeCodec upgradeCodec;
    private UpgradeEvent currentUpgradeEvent;

    /**
     * Constructs the client upgrade handler.
     *
     * @param sourceCodec the codec that is being used initially.
     * @param upgradeCodec the codec that the client would like to upgrade to.
     * @param maxContentLength the maximum length of the aggregated content.
     */
    public HttpClientUpgradeHandler(SourceCodec sourceCodec, UpgradeCodec upgradeCodec,
                                    int maxContentLength) {
        super(maxContentLength);
        this.sourceCodec = ObjectUtil.checkNotNull(sourceCodec, "sourceCodec");

Frequently Asked Questions

What is the HttpClientUpgradeHandler class?
HttpClientUpgradeHandler is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java.
Where is HttpClientUpgradeHandler defined?
HttpClientUpgradeHandler is defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpClientUpgradeHandler.java at line 40.

Analyze Your Own Codebase

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

Try Supermodel Free