|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.netty.channel.SimpleChannelHandler
org.jboss.netty.handler.codec.http.HttpContentEncoder
public abstract class HttpContentEncoder
Encodes the content of the outbound HttpResponse
and HttpChunk
.
The original content is replaced with the new content encoded by the
EncoderEmbedder
, which is created by newContentEncoder(String)
.
Once encoding is finished, the value of the 'Content-Encoding' header
is set to the target content encoding, as returned by getTargetContentEncoding(String)
.
Also, the 'Content-Length' header is updated to the length of the
encoded content. If there is no supported encoding in the
corresponding HttpRequest
's "Accept-Encoding"
header,
newContentEncoder(String)
should return null
so that no
encoding occurs (i.e. pass-through).
Please note that this is an abstract class. You have to extend this class
and implement newContentEncoder(String)
and getTargetContentEncoding(String)
properly to make this class functional. For example, refer to the source
code of HttpContentCompressor
.
This handler must be placed after HttpMessageEncoder
in the pipeline
so that this handler can intercept HTTP responses before HttpMessageEncoder
converts them into ChannelBuffer
s.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
---|
ChannelHandler.Sharable |
Constructor Summary | |
---|---|
protected |
HttpContentEncoder()
Creates a new instance. |
Method Summary | |
---|---|
protected abstract String |
getTargetContentEncoding(String acceptEncoding)
Returns the expected content encoding of the encoded content. |
void |
messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
Invoked when a message object (e.g: ChannelBuffer ) was received
from a remote peer. |
protected abstract EncoderEmbedder<ChannelBuffer> |
newContentEncoder(String acceptEncoding)
Returns a new EncoderEmbedder that encodes the HTTP message
content. |
void |
writeRequested(ChannelHandlerContext ctx,
MessageEvent e)
Invoked when Channel.write(Object) is called. |
Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler |
---|
bindRequested, channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, exceptionCaught, handleDownstream, handleUpstream, setInterestOpsRequested, unbindRequested, writeComplete |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected HttpContentEncoder()
Method Detail |
---|
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
SimpleChannelHandler
ChannelBuffer
) was received
from a remote peer.
messageReceived
in class SimpleChannelHandler
Exception
public void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception
SimpleChannelHandler
Channel.write(Object)
is called.
writeRequested
in class SimpleChannelHandler
Exception
protected abstract EncoderEmbedder<ChannelBuffer> newContentEncoder(String acceptEncoding) throws Exception
EncoderEmbedder
that encodes the HTTP message
content.
acceptEncoding
- the value of the "Accept-Encoding"
header
EncoderEmbedder
if there is a supported encoding
in acceptEncoding
. null
otherwise.
Exception
protected abstract String getTargetContentEncoding(String acceptEncoding) throws Exception
acceptEncoding
- the value of the "Accept-Encoding"
header
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |