Module io.netty5.codec.http
Package io.netty5.handler.codec.http
Class HttpClientUpgradeHandler<C extends HttpContent<C>>
- java.lang.Object
-
- io.netty5.channel.ChannelHandlerAdapter
-
- io.netty5.handler.codec.MessageToMessageDecoder<I>
-
- io.netty5.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent<C>,FullHttpMessage<?>>
-
- io.netty5.handler.codec.http.HttpObjectAggregator<C>
-
- io.netty5.handler.codec.http.HttpClientUpgradeHandler<C>
-
- All Implemented Interfaces:
ChannelHandler
public class HttpClientUpgradeHandler<C extends HttpContent<C>> extends HttpObjectAggregator<C>
Client-side handler for handling an HTTP upgrade handshake to another protocol. When the first HTTP request is sent, this handler will add all appropriate headers to perform an upgrade to the new protocol. If the upgrade fails (i.e. response is not 101 Switching Protocols), this handler simply removes itself from the pipeline. If the upgrade is successful, upgrades the pipeline to the new protocol.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
HttpClientUpgradeHandler.SourceCodec
The source codec that is used in the pipeline initially.static interface
HttpClientUpgradeHandler.UpgradeCodec
A codec that the source can be upgraded to.static class
HttpClientUpgradeHandler.UpgradeEvent
User events that are fired to notify about upgrade status.
-
Constructor Summary
Constructors Constructor Description HttpClientUpgradeHandler(HttpClientUpgradeHandler.SourceCodec sourceCodec, HttpClientUpgradeHandler.UpgradeCodec upgradeCodec, int maxContentLength)
Constructs the client upgrade handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
decode(ChannelHandlerContext ctx, HttpObject msg)
Decode from one message to another.Future<Void>
write(ChannelHandlerContext ctx, Object msg)
Called once a write operation is made.-
Methods inherited from class io.netty5.handler.codec.http.HttpObjectAggregator
aggregate, beginAggregation, channelExceptionCaught, closeAfterContinueResponse, finishAggregation, handleOversizedMessage, ignoreContentAfterContinueResponse, isAggregated, isContentLengthInvalid, isLastContentMessage, lengthForAggregation, lengthForContent, newContinueResponse, tryContentMessage, tryStartMessage
-
Methods inherited from class io.netty5.handler.codec.MessageAggregator
acceptInboundMessage, channelInactive, channelReadComplete, ctx, handlerAdded, handlerRemoved, maxContentLength
-
Methods inherited from class io.netty5.handler.codec.MessageToMessageDecoder
channelRead, decodeAndClose
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelInboundEvent, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown
-
-
-
-
Constructor Detail
-
HttpClientUpgradeHandler
public HttpClientUpgradeHandler(HttpClientUpgradeHandler.SourceCodec sourceCodec, HttpClientUpgradeHandler.UpgradeCodec upgradeCodec, int maxContentLength)
Constructs the client upgrade handler.- Parameters:
sourceCodec
- the codec that is being used initially.upgradeCodec
- the codec that the client would like to upgrade to.maxContentLength
- the maximum length of the aggregated content.
-
-
Method Detail
-
write
public Future<Void> write(ChannelHandlerContext ctx, Object msg)
Description copied from interface:ChannelHandler
Called once a write operation is made. The write operation will write the messages through theChannelPipeline
. Those are then ready to be flushed to the actualChannel
onceChannel.flush()
is called.- Parameters:
ctx
- theChannelHandlerContext
for which the write operation is mademsg
- the message to write- Returns:
- the
Future
which will be notified once the operation completes.
-
decode
protected void decode(ChannelHandlerContext ctx, HttpObject msg) throws Exception
Description copied from class:MessageToMessageDecoder
Decode from one message to another. This method will be called for each written message that can be handled by this decoder.The message will be disposed of after this call.
Subclasses that wish to sometimes pass messages through, should instead override the
MessageToMessageDecoder.decodeAndClose(ChannelHandlerContext, Object)
method.- Overrides:
decode
in classMessageAggregator<HttpObject,HttpMessage,HttpContent<C extends HttpContent<C>>,FullHttpMessage<?>>
- Parameters:
ctx
- theChannelHandlerContext
which thisMessageToMessageDecoder
belongs tomsg
- the message to decode to another one- Throws:
Exception
- is thrown if an error occurs
-
-