public class HttpServerUpgradeHandler extends HttpObjectAggregator
| Modifier and Type | Class and Description |
|---|---|
static interface |
HttpServerUpgradeHandler.SourceCodec
The source codec that is used in the pipeline initially.
|
static interface |
HttpServerUpgradeHandler.UpgradeCodec
A codec that the source can be upgraded to.
|
static interface |
HttpServerUpgradeHandler.UpgradeCodecFactory
Creates a new
HttpServerUpgradeHandler.UpgradeCodec for the requested protocol name. |
static class |
HttpServerUpgradeHandler.UpgradeEvent
User event that is fired to notify about the completion of an HTTP upgrade
to another protocol.
|
ChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
private boolean |
handlingUpgrade |
private HttpServerUpgradeHandler.SourceCodec |
sourceCodec |
private HttpServerUpgradeHandler.UpgradeCodecFactory |
upgradeCodecFactory |
| Constructor and Description |
|---|
HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec,
HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory)
Constructs the upgrader with the supported codecs.
|
HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec,
HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory,
int maxContentLength)
Constructs the upgrader with the supported codecs.
|
| Modifier and Type | Method and Description |
|---|---|
private static FullHttpResponse |
createUpgradeResponse(java.lang.CharSequence upgradeProtocol)
Creates the 101 Switching Protocols response message.
|
protected void |
decode(ChannelHandlerContext ctx,
HttpObject msg,
java.util.List<java.lang.Object> out)
Decode from one message to an other.
|
private static boolean |
isUpgradeRequest(HttpObject msg)
Determines whether or not the message is an HTTP upgrade request.
|
private static java.util.List<java.lang.CharSequence> |
splitHeader(java.lang.CharSequence header)
Splits a comma-separated header value.
|
private boolean |
upgrade(ChannelHandlerContext ctx,
FullHttpRequest request)
Attempts to upgrade to the protocol(s) identified by the
HttpHeaderNames.UPGRADE header (if provided
in the request). |
aggregate, beginAggregation, closeAfterContinueResponse, finishAggregation, handleOversizedMessage, ignoreContentAfterContinueResponse, isAggregated, isContentLengthInvalid, isContentMessage, isLastContentMessage, isStartMessage, newContinueResponseacceptInboundMessage, channelInactive, channelReadComplete, ctx, handlerAdded, handlerRemoved, isHandlingOversizedMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponentschannelReadchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, isSharableprivate final HttpServerUpgradeHandler.SourceCodec sourceCodec
private final HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory
private boolean handlingUpgrade
public HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec, HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory)
The handler instantiated by this constructor will reject an upgrade request with non-empty content.
It should not be a concern because an upgrade request is most likely a GET request.
If you have a client that sends a non-GET upgrade request, please consider using
HttpServerUpgradeHandler(SourceCodec, UpgradeCodecFactory, int) to specify the maximum
length of the content of an upgrade request.
sourceCodec - the codec that is being used initiallyupgradeCodecFactory - the factory that creates a new upgrade codec
for one of the requested upgrade protocolspublic HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec, HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory, int maxContentLength)
sourceCodec - the codec that is being used initiallyupgradeCodecFactory - the factory that creates a new upgrade codec
for one of the requested upgrade protocolsmaxContentLength - the maximum length of the content of an upgrade requestprotected void decode(ChannelHandlerContext ctx, HttpObject msg, java.util.List<java.lang.Object> out) throws java.lang.Exception
MessageToMessageDecoderdecode in class MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>ctx - the ChannelHandlerContext which this MessageToMessageDecoder belongs tomsg - the message to decode to an other oneout - the List to which decoded messages should be addedjava.lang.Exception - is thrown if an error occursprivate static boolean isUpgradeRequest(HttpObject msg)
private boolean upgrade(ChannelHandlerContext ctx, FullHttpRequest request)
HttpHeaderNames.UPGRADE header (if provided
in the request).ctx - the context for this handler.request - the HTTP request.true if the upgrade occurred, otherwise false.private static FullHttpResponse createUpgradeResponse(java.lang.CharSequence upgradeProtocol)
private static java.util.List<java.lang.CharSequence> splitHeader(java.lang.CharSequence header)