Class HttpMessageEncoder
- java.lang.Object
-
- org.jboss.netty.handler.codec.oneone.OneToOneEncoder
-
- org.jboss.netty.handler.codec.http.HttpMessageEncoder
-
- All Implemented Interfaces:
ChannelDownstreamHandler,ChannelHandler
- Direct Known Subclasses:
HttpRequestEncoder,HttpResponseEncoder,RtspMessageEncoder
public abstract class HttpMessageEncoder extends OneToOneEncoder
Encodes anHttpMessageor anHttpChunkinto aChannelBuffer.Extensibility
Please note that this encoder is designed to be extended to implement a protocol derived from HTTP, such as RTSP and ICAP. To implement the encoder of such a derived protocol, extend this class and implement all abstract methods properly.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]CRLFprivate static ChannelBufferLAST_CHUNKprivate booleantransferEncodingChunked
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpMessageEncoder()Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static bytec2b(char c)protected java.lang.Objectencode(ChannelHandlerContext ctx, Channel channel, java.lang.Object msg)Transforms the specified message into another message and return the transformed message.protected static voidencodeAscii(java.lang.String s, ChannelBuffer buf)private static voidencodeHeader(ChannelBuffer buf, java.lang.String header, java.lang.String value)private static voidencodeHeaders(ChannelBuffer buf, HttpMessage message)protected abstract voidencodeInitialLine(ChannelBuffer buf, HttpMessage message)private static voidencodeTrailingHeaders(ChannelBuffer buf, HttpChunkTrailer trailer)-
Methods inherited from class org.jboss.netty.handler.codec.oneone.OneToOneEncoder
doEncode, handleDownstream
-
-
-
-
Field Detail
-
CRLF
private static final byte[] CRLF
-
LAST_CHUNK
private static final ChannelBuffer LAST_CHUNK
-
transferEncodingChunked
private volatile boolean transferEncodingChunked
-
-
Method Detail
-
encode
protected java.lang.Object encode(ChannelHandlerContext ctx, Channel channel, java.lang.Object msg) throws java.lang.Exception
Description copied from class:OneToOneEncoderTransforms the specified message into another message and return the transformed message. Note that you can not returnnull, unlike you can inOneToOneDecoder.decode(ChannelHandlerContext, Channel, Object); you must return something, at leastChannelBuffers.EMPTY_BUFFER.- Specified by:
encodein classOneToOneEncoder- Throws:
java.lang.Exception
-
encodeHeaders
private static void encodeHeaders(ChannelBuffer buf, HttpMessage message)
-
encodeTrailingHeaders
private static void encodeTrailingHeaders(ChannelBuffer buf, HttpChunkTrailer trailer)
-
encodeHeader
private static void encodeHeader(ChannelBuffer buf, java.lang.String header, java.lang.String value) throws java.io.UnsupportedEncodingException
- Throws:
java.io.UnsupportedEncodingException
-
encodeAscii
protected static void encodeAscii(java.lang.String s, ChannelBuffer buf)
-
c2b
private static byte c2b(char c)
-
encodeInitialLine
protected abstract void encodeInitialLine(ChannelBuffer buf, HttpMessage message) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-