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 org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
private static final ChannelBuffer
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte
c2b
(char c) protected Object
encode
(ChannelHandlerContext ctx, Channel channel, Object msg) Transforms the specified message into another message and return the transformed message.protected static void
encodeAscii
(String s, ChannelBuffer buf) private static void
encodeHeader
(ChannelBuffer buf, String header, String value) private static void
encodeHeaders
(ChannelBuffer buf, HttpMessage message) protected abstract void
encodeInitialLine
(ChannelBuffer buf, HttpMessage message) private static void
encodeTrailingHeaders
(ChannelBuffer buf, HttpChunkTrailer trailer) Methods inherited from class org.jboss.netty.handler.codec.oneone.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:OneToOneEncoder
Transforms 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:
encode
in 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
-