Package com.linkedin.alpini.netty4.misc
Class BasicHttpObjectDecoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.ByteToMessageDecoder
-
- io.netty.handler.codec.http.HttpObjectDecoder
-
- com.linkedin.alpini.netty4.misc.BasicHttpObjectDecoder
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
HttpContentMultiPartDecode
public abstract class BasicHttpObjectDecoder extends io.netty.handler.codec.http.HttpObjectDecoder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BasicHttpObjectDecoder.State
The internal state ofBasicHttpObjectDecoder
.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
validateHeaders
-
Constructor Summary
Constructors Modifier Constructor Description protected
BasicHttpObjectDecoder()
Creates a new instance with the defaultmaxInitialLineLength (4096
},maxHeaderSize (8192)
, andmaxChunkSize (8192)
.protected
BasicHttpObjectDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported)
Creates a new instance with the specified parameters.protected
BasicHttpObjectDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported, boolean validateHeaders)
Creates a new instance with the specified parameters.protected
BasicHttpObjectDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported, boolean validateHeaders, int initialBufferSize)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract io.netty.handler.codec.http.HttpMessage
createInvalidMessage()
protected io.netty.handler.codec.http.HttpMessage
createMessage(ByteBufAsciiString[] initialLine)
protected abstract io.netty.handler.codec.http.HttpMessage
createMessage(java.lang.String[] initialLine)
protected void
decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, java.util.List<java.lang.Object> out)
protected void
decodeLast(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out)
BasicHttpObjectDecoder.State
getDecoderState()
protected boolean
isContentAlwaysEmpty(io.netty.handler.codec.http.HttpMessage msg)
protected abstract boolean
isDecodingRequest()
protected boolean
isSwitchingToNonHttp1Protocol(io.netty.handler.codec.http.HttpResponse msg)
Returns true if the server switched to a different protocol than HTTP/1.0 or HTTP/1.1, e.g.void
reset()
Resets the state of the decoder so that it is ready to decode a new message.void
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt)
-
Methods inherited from class io.netty.handler.codec.http.HttpObjectDecoder
handleTransferEncodingChunkedWithContentLength
-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
-
-
-
-
Constructor Detail
-
BasicHttpObjectDecoder
protected BasicHttpObjectDecoder()
Creates a new instance with the defaultmaxInitialLineLength (4096
},maxHeaderSize (8192)
, andmaxChunkSize (8192)
.
-
BasicHttpObjectDecoder
protected BasicHttpObjectDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported)
Creates a new instance with the specified parameters.
-
BasicHttpObjectDecoder
protected BasicHttpObjectDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported, boolean validateHeaders)
Creates a new instance with the specified parameters.
-
BasicHttpObjectDecoder
protected BasicHttpObjectDecoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported, boolean validateHeaders, int initialBufferSize)
-
-
Method Detail
-
getDecoderState
public final BasicHttpObjectDecoder.State getDecoderState()
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, java.util.List<java.lang.Object> out) throws java.lang.Exception
- Overrides:
decode
in classio.netty.handler.codec.http.HttpObjectDecoder
- Throws:
java.lang.Exception
-
decodeLast
protected void decodeLast(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
- Overrides:
decodeLast
in classio.netty.handler.codec.http.HttpObjectDecoder
- Throws:
java.lang.Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt) throws java.lang.Exception
- Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.handler.codec.http.HttpObjectDecoder
- Throws:
java.lang.Exception
-
isContentAlwaysEmpty
protected boolean isContentAlwaysEmpty(io.netty.handler.codec.http.HttpMessage msg)
- Overrides:
isContentAlwaysEmpty
in classio.netty.handler.codec.http.HttpObjectDecoder
-
isSwitchingToNonHttp1Protocol
protected boolean isSwitchingToNonHttp1Protocol(io.netty.handler.codec.http.HttpResponse msg)
Returns true if the server switched to a different protocol than HTTP/1.0 or HTTP/1.1, e.g. HTTP/2 or Websocket. Returns false if the upgrade happened in a different layer, e.g. upgrade from HTTP/1.1 to HTTP/1.1 over TLS.- Overrides:
isSwitchingToNonHttp1Protocol
in classio.netty.handler.codec.http.HttpObjectDecoder
-
reset
public void reset()
Resets the state of the decoder so that it is ready to decode a new message. This method is useful for handling a rejected request withExpect: 100-continue
header.- Overrides:
reset
in classio.netty.handler.codec.http.HttpObjectDecoder
-
isDecodingRequest
protected abstract boolean isDecodingRequest()
- Specified by:
isDecodingRequest
in classio.netty.handler.codec.http.HttpObjectDecoder
-
createMessage
protected io.netty.handler.codec.http.HttpMessage createMessage(ByteBufAsciiString[] initialLine) throws java.lang.Exception
- Throws:
java.lang.Exception
-
createMessage
protected abstract io.netty.handler.codec.http.HttpMessage createMessage(java.lang.String[] initialLine) throws java.lang.Exception
- Specified by:
createMessage
in classio.netty.handler.codec.http.HttpObjectDecoder
- Throws:
java.lang.Exception
-
createInvalidMessage
protected abstract io.netty.handler.codec.http.HttpMessage createInvalidMessage()
- Specified by:
createInvalidMessage
in classio.netty.handler.codec.http.HttpObjectDecoder
-
-