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| 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.
|
HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec,
HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory,
int maxContentLength,
boolean validateHeaders)
Constructs the upgrader with the supported codecs.
|
HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec,
HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory,
int maxContentLength,
HttpHeadersFactory headersFactory,
HttpHeadersFactory trailersFactory)
Constructs the upgrader with the supported codecs.
|
| Modifier and Type | Method and Description |
|---|---|
protected FullHttpMessage |
beginAggregation(HttpMessage start,
ByteBuf content)
Creates a new aggregated message from the specified start message and the specified content.
|
protected void |
decode(ChannelHandlerContext ctx,
HttpObject msg,
List<Object> out)
Decode from one message to an other.
|
protected boolean |
shouldHandleUpgradeRequest(HttpRequest req)
Determines whether the specified upgrade
HttpRequest should be handled by this handler or not. |
aggregate, closeAfterContinueResponse, finishAggregation, handleOversizedMessage, ignoreContentAfterContinueResponse, isAggregated, isContentLengthInvalid, isContentMessage, isLastContentMessage, isStartMessage, newContinueResponseacceptInboundMessage, channelInactive, channelReadComplete, ctx, handlerAdded, handlerRemoved, isHandlingOversizedMessage, maxContentLength, maxCumulationBufferComponents, releaseCurrentMessage, setMaxCumulationBufferComponentschannelReadchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, isSharablepublic 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 requestpublic HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec, HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory, int maxContentLength, boolean validateHeaders)
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 requestvalidateHeaders - validate the header names and values of the upgrade response.public HttpServerUpgradeHandler(HttpServerUpgradeHandler.SourceCodec sourceCodec, HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory, int maxContentLength, HttpHeadersFactory headersFactory, HttpHeadersFactory trailersFactory)
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 requestheadersFactory - The HttpHeadersFactory to use for headers.
The recommended default factory is DefaultHttpHeadersFactory.headersFactory().trailersFactory - The HttpHeadersFactory to use for trailers.
The recommended default factory is DefaultHttpHeadersFactory.trailersFactory().protected void decode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws 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 addedException - is thrown if an error occursprotected FullHttpMessage beginAggregation(HttpMessage start, ByteBuf content) throws Exception
MessageAggregatorByteBufHolder, its content is appended to the specified content.
This aggregator will continue to append the received content to the specified content.beginAggregation in class HttpObjectAggregatorExceptionprotected boolean shouldHandleUpgradeRequest(HttpRequest req)
HttpRequest should be handled by this handler or not.
This method will be invoked only when the request contains an Upgrade header.
It always returns true by default, which means any request with an Upgrade header
will be handled. You can override this method to ignore certain Upgrade headers, for example:
{@codeCopyright © 2008–2025 The Netty Project. All rights reserved.