HttpServerUpgradeHandler Class — netty Architecture
Architecture documentation for the HttpServerUpgradeHandler class in HttpServerUpgradeHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 9c8c1840_4e39_0876_abe2_bb3ce8067466["HttpServerUpgradeHandler"] 5d7a491e_b999_dfe7_d7db_9b5071c06005["HttpServerUpgradeHandler.java"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|defined in| 5d7a491e_b999_dfe7_d7db_9b5071c06005 a5d58799_db0a_4984_3659_7d1823460079["HttpServerUpgradeHandler()"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|method| a5d58799_db0a_4984_3659_7d1823460079 71a1fb51_f416_1d4b_7593_4149e6ec5c5d["decode()"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|method| 71a1fb51_f416_1d4b_7593_4149e6ec5c5d 370ed15c_098c_96a0_f3a9_70f3a839acc8["FullHttpMessage()"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|method| 370ed15c_098c_96a0_f3a9_70f3a839acc8 facc240a_d60c_c641_9420_a67c114728b0["shouldHandleUpgradeRequest()"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|method| facc240a_d60c_c641_9420_a67c114728b0 149aae54_88df_d06f_7ef6_3a140cffc9ad["upgrade()"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|method| 149aae54_88df_d06f_7ef6_3a140cffc9ad b65c6308_9507_9c00_a912_fee87fa6e180["FullHttpResponse()"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|method| b65c6308_9507_9c00_a912_fee87fa6e180 c68ee1f2_acba_ff86_bef6_328b183214dd["splitHeader()"] 9c8c1840_4e39_0876_abe2_bb3ce8067466 -->|method| c68ee1f2_acba_ff86_bef6_328b183214dd
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java lines 41–497
public class HttpServerUpgradeHandler extends HttpObjectAggregator {
/**
* The source codec that is used in the pipeline initially.
*/
public interface SourceCodec {
/**
* 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 {
/**
* Gets all protocol-specific headers required by this protocol for a successful upgrade.
* Any supplied header will be required to appear in the {@link HttpHeaderNames#CONNECTION} header as well.
*/
Collection<CharSequence> requiredUpgradeHeaders();
/**
* Prepares the {@code upgradeHeaders} for a protocol update based upon the contents of {@code upgradeRequest}.
* This method returns a boolean value to proceed or abort the upgrade in progress. If {@code false} is
* returned, the upgrade is aborted and the {@code upgradeRequest} will be passed through the inbound pipeline
* as if no upgrade was performed. If {@code true} is returned, the upgrade will proceed to the next
* step which invokes {@link #upgradeTo}. When returning {@code true}, you can add headers to
* the {@code upgradeHeaders} so that they are added to the 101 Switching protocols response.
*/
boolean prepareUpgradeResponse(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest,
HttpHeaders upgradeHeaders);
/**
* 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 upgradeRequest the request that triggered the upgrade to this protocol.
*/
void upgradeTo(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest);
}
/**
* Creates a new {@link UpgradeCodec} for the requested protocol name.
*/
public interface UpgradeCodecFactory {
/**
* Invoked by {@link HttpServerUpgradeHandler} for all the requested protocol names in the order of
* the client preference. The first non-{@code null} {@link UpgradeCodec} returned by this method
* will be selected.
*
* @return a new {@link UpgradeCodec}, or {@code null} if the specified protocol name is not supported
*/
UpgradeCodec newUpgradeCodec(CharSequence protocol);
}
/**
* User event that is fired to notify about the completion of an HTTP upgrade
* to another protocol. Contains the original upgrade request so that the response
* (if required) can be sent using the new protocol.
*/
public static final class UpgradeEvent implements ReferenceCounted {
private final CharSequence protocol;
private final FullHttpRequest upgradeRequest;
UpgradeEvent(CharSequence protocol, FullHttpRequest upgradeRequest) {
this.protocol = protocol;
this.upgradeRequest = upgradeRequest;
}
/**
* The protocol that the channel has been upgraded to.
*/
public CharSequence protocol() {
return protocol;
}
/**
* Gets the request that triggered the protocol upgrade.
*/
Source
Frequently Asked Questions
What is the HttpServerUpgradeHandler class?
HttpServerUpgradeHandler is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java.
Where is HttpServerUpgradeHandler defined?
HttpServerUpgradeHandler is defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java at line 41.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free