GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Overview
  • Use
  • Tree
  • Deprecated
  • Index
  • Search
  • Help
  • io.netty.handler.codec.http
  • HttpObjectEncoder

This view

  • Original page
  • New address

GeezerVison is showing netty.io — HttpObjectEncoder (Netty API Reference (4.1.141.Final))

Class HttpObjectEncoder<H extends HttpMessage>

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToMessageEncoder<Object>
io.netty.handler.codec.http.HttpObjectEncoder<H>
All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler
Direct Known Subclasses:
HttpRequestEncoder, HttpResponseEncoder, RtspEncoder, RtspObjectEncoder

public abstract class HttpObjectEncoder<H extends HttpMessage> extends MessageToMessageEncoder<Object>
Encodes an HttpMessage or an HttpContent into a ByteBuf.

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
    Modifier and Type
    Interface
    Description
    static @interface 
    ChannelHandler.Sharable
    Indicates that the same instance of the annotated ChannelHandler can be added to one or more ChannelPipelines multiple times without a race condition.
  • Constructor Summary

    Constructors
    Constructor
    Description
    HttpObjectEncoder()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    acceptOutboundMessage(Object msg)
    Returns true if the given message should be handled.
    protected void
    encode(ChannelHandlerContext ctx, Object msg, List<Object> out)
    Encode from one message to an other.
    protected static void
    encodeAscii(String s, ByteBuf buf)
    Deprecated.
    protected void
    encodeHeaders(HttpHeaders headers, ByteBuf buf)
    Encode the HttpHeaders into a ByteBuf.
    protected abstract void
    encodeInitialLine(ByteBuf buf, H message)
     
    protected boolean
    isContentAlwaysEmpty(H msg)
    Determine whether a message has a content or not.
    protected void
    sanitizeHeadersBeforeEncode(H msg, boolean isAlwaysEmpty)
    Allows to sanitize headers of the message before encoding these.
    void
    write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
    Calls ChannelOutboundInvoker.write(Object, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelOutboundHandlerAdapter

    bind, close, connect, deregister, disconnect, flush, read
    Modifier and Type
    Method
    Description
    void
    bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.bind(SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    close(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    deregister(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.deregister(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    disconnect(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.disconnect(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    flush(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.flush() to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    read(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.read() to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelHandlerAdapter

    ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
    Modifier and Type
    Method
    Description
    protected void
    ensureNotSharable()
    Throws IllegalStateException if ChannelHandlerAdapter.isSharable() returns true
    void
    exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
    Deprecated.
    is part of ChannelInboundHandler
    void
    handlerAdded(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    void
    handlerRemoved(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    boolean
    isSharable()
    Return true if the implementation is ChannelHandler.Sharable and so can be added to different ChannelPipelines.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HttpObjectEncoder

      public HttpObjectEncoder()
  • Method Details

    • write

      public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
      Description copied from class: ChannelOutboundHandlerAdapter
      Calls ChannelOutboundInvoker.write(Object, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      write in interface ChannelOutboundHandler
      Overrides:
      write in class MessageToMessageEncoder<Object>
      Parameters:
      ctx - the ChannelHandlerContext for which the write operation is made
      msg - the message to write
      promise - the ChannelPromise to notify once the operation completes
      Throws:
      Exception - thrown if an error occurs
    • encode

      protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception
      Description copied from class: MessageToMessageEncoder
      Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.
      Specified by:
      encode in class MessageToMessageEncoder<Object>
      Parameters:
      ctx - the ChannelHandlerContext which this MessageToMessageEncoder belongs to
      msg - the message to encode to an other one
      out - the List into which the encoded msg should be added needs to do some kind of aggregation
      Throws:
      Exception - is thrown if an error occurs
    • encodeHeaders

      protected void encodeHeaders(HttpHeaders headers, ByteBuf buf)
      Encode the HttpHeaders into a ByteBuf.
    • sanitizeHeadersBeforeEncode

      protected void sanitizeHeadersBeforeEncode(H msg, boolean isAlwaysEmpty)
      Allows to sanitize headers of the message before encoding these.
    • isContentAlwaysEmpty

      protected boolean isContentAlwaysEmpty(H msg)
      Determine whether a message has a content or not. Some message may have headers indicating a content without having an actual content, e.g the response to an HEAD or CONNECT request.
      Parameters:
      msg - the message to test
      Returns:
      true to signal the message has no content
    • acceptOutboundMessage

      public boolean acceptOutboundMessage(Object msg) throws Exception
      Description copied from class: MessageToMessageEncoder
      Returns true if the given message should be handled. If false it will be passed to the next ChannelOutboundHandler in the ChannelPipeline.
      Overrides:
      acceptOutboundMessage in class MessageToMessageEncoder<Object>
      Throws:
      Exception
    • encodeAscii

      @Deprecated protected static void encodeAscii(String s, ByteBuf buf)
      Deprecated.
    • encodeInitialLine

      protected abstract void encodeInitialLine(ByteBuf buf, H message) throws Exception
      Throws:
      Exception
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.