org.jboss.netty.handler.codec.http
类 HttpContentEncoder

java.lang.Object
  继承者 org.jboss.netty.channel.SimpleChannelHandler
      继承者 org.jboss.netty.handler.codec.http.HttpContentEncoder
所有已实现的接口:
ChannelDownstreamHandler, ChannelHandler, ChannelUpstreamHandler
直接已知子类:
HttpContentCompressor

public abstract class HttpContentEncoder
extends SimpleChannelHandler

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 ChannelBuffers.


嵌套类摘要
 
从接口 org.jboss.netty.channel.ChannelHandler 继承的嵌套类/接口
ChannelHandler.Sharable
 
方法摘要
 void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
          当一个远程消息对象(如: ChannelBuffer)被接收时调用.
 void writeRequested(ChannelHandlerContext ctx, MessageEvent e)
          当Channel.write(Object)被调用时调用.
 
从类 org.jboss.netty.channel.SimpleChannelHandler 继承的方法
bindRequested, channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, exceptionCaught, handleDownstream, handleUpstream, setInterestOpsRequested, unbindRequested, writeComplete
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

方法详细信息

messageReceived

public void messageReceived(ChannelHandlerContext ctx,
                            MessageEvent e)
                     throws java.lang.Exception
从类 SimpleChannelHandler 复制的描述
当一个远程消息对象(如: ChannelBuffer)被接收时调用.

覆盖:
SimpleChannelHandler 中的 messageReceived
抛出:
java.lang.Exception

writeRequested

public void writeRequested(ChannelHandlerContext ctx,
                           MessageEvent e)
                    throws java.lang.Exception
从类 SimpleChannelHandler 复制的描述
Channel.write(Object)被调用时调用.

覆盖:
SimpleChannelHandler 中的 writeRequested
抛出:
java.lang.Exception