Package io.netty.handler.codec.http
Class HttpClientUpgradeHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.MessageToMessageDecoder<I>
io.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage,HttpContent,FullHttpMessage>
io.netty.handler.codec.http.HttpObjectAggregator
io.netty.handler.codec.http.HttpClientUpgradeHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public class HttpClientUpgradeHandler
extends HttpObjectAggregator
implements io.netty.channel.ChannelOutboundHandler
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 ClassesModifier and TypeClassDescriptionstatic interfaceThe source codec that is used in the pipeline initially.static interfaceA codec that the source can be upgraded to.static enumUser events that are fired to notify about upgrade status.Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionHttpClientUpgradeHandler(HttpClientUpgradeHandler.SourceCodec sourceCodec, HttpClientUpgradeHandler.UpgradeCodec upgradeCodec, int maxContentLength) Constructs the client upgrade handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(io.netty.channel.ChannelHandlerContext ctx, SocketAddress localAddress, io.netty.channel.ChannelPromise promise) voidclose(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) voidconnect(io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, io.netty.channel.ChannelPromise promise) protected voiddecode(io.netty.channel.ChannelHandlerContext ctx, HttpObject msg, List<Object> out) voidderegister(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) voiddisconnect(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) voidflush(io.netty.channel.ChannelHandlerContext ctx) voidread(io.netty.channel.ChannelHandlerContext ctx) voidwrite(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) Methods inherited from class io.netty.handler.codec.http.HttpObjectAggregator
aggregate, beginAggregation, closeAfterContinueResponse, finishAggregation, handleOversizedMessage, ignoreContentAfterContinueResponse, isAggregated, isContentLengthInvalid, isContentMessage, isLastContentMessage, isStartMessage, newContinueResponseMethods inherited from class io.netty.handler.codec.MessageAggregator
acceptInboundMessage, channelInactive, channelReadComplete, ctx, handlerAdded, handlerRemoved, isHandlingOversizedMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponentsMethods inherited from class io.netty.handler.codec.MessageToMessageDecoder
channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
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 Details
-
bind
public void bind(io.netty.channel.ChannelHandlerContext ctx, SocketAddress localAddress, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
bindin interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
connect
public void connect(io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
connectin interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
disconnect
public void disconnect(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
disconnectin interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
close
public void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
closein interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
deregister
public void deregister(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
deregisterin interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
read
- Specified by:
readin interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
writein interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
flush
- Specified by:
flushin interfaceio.netty.channel.ChannelOutboundHandler- Throws:
Exception
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception - Overrides:
decodein classio.netty.handler.codec.MessageAggregator<HttpObject,HttpMessage, HttpContent, FullHttpMessage> - Throws:
Exception
-