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
Encodes an
HttpMessage or an HttpChunk into
a ChannelBuffer.
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 ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]private static final ChannelBufferprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static bytec2b(char c) protected Objectencode(ChannelHandlerContext ctx, Channel channel, Object msg) Transforms the specified message into another message and return the transformed message.protected static voidencodeAscii(String s, ChannelBuffer buf) private static voidencodeHeader(ChannelBuffer buf, String header, 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 OneToOneEncoder
doEncode, handleDownstream
-
Field Details
-
CRLF
private static final byte[] CRLF -
LAST_CHUNK
-
transferEncodingChunked
private volatile boolean transferEncodingChunked
-
-
Constructor Details
-
HttpMessageEncoder
protected HttpMessageEncoder()Creates a new instance.
-
-
Method Details
-
encode
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:
Exception
-
encodeHeaders
-
encodeTrailingHeaders
-
encodeHeader
private static void encodeHeader(ChannelBuffer buf, String header, String value) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
encodeAscii
-
c2b
private static byte c2b(char c) -
encodeInitialLine
- Throws:
Exception
-