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
  • HttpServerCodec

This view

  • Original page
  • New address

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

Class HttpServerCodec

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.channel.CombinedChannelDuplexHandler<HttpRequestDecoder, HttpResponseEncoder>
io.netty.handler.codec.http.HttpServerCodec
All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler, HttpServerUpgradeHandler.SourceCodec

public final class HttpServerCodec extends CombinedChannelDuplexHandler<HttpRequestDecoder, HttpResponseEncoder> implements HttpServerUpgradeHandler.SourceCodec
A combination of HttpRequestDecoder and HttpResponseEncoder which enables easier server side HTTP implementation.

Header Validation

It is recommended to always enable header validation.

Without header validation, your system can become vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') .

This recommendation stands even when both peers in the HTTP exchange are trusted, as it helps with defence-in-depth.

See Also:
  • HttpClientCodec
  • 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
    HttpServerCodec()
    Creates a new instance with the default decoder options (maxInitialLineLength (4096), maxHeaderSize (8192), and maxChunkSize (8192)).
    HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize)
    Creates a new instance with the specified decoder options.
    HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders)
    Deprecated.
    Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
    HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders, int initialBufferSize)
    Deprecated.
    Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
    HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths)
    Deprecated.
    Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
    HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths, boolean allowPartialChunks)
    Deprecated.
    Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
    HttpServerCodec(HttpDecoderConfig config)
    Creates a new instance with the specified decoder configuration.
    HttpServerCodec(HttpDecoderConfig config, int maxPipelineDepth)
    Creates a new instance with the specified decoder configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    upgradeFrom(ChannelHandlerContext ctx)
    Upgrades to another protocol from HTTP.

    Methods inherited from class CombinedChannelDuplexHandler

    bind, channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, handlerAdded, handlerRemoved, inboundHandler, init, outboundHandler, read, removeInboundHandler, removeOutboundHandler, userEventTriggered, write
    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
    channelActive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelInactive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelInactive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelRead(ChannelHandlerContext ctx, Object msg)
    Calls ChannelHandlerContext.fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelReadComplete(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelReadComplete() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelRegistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelRegistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelUnregistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelUnregistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelWritabilityChanged(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelWritabilityChanged() to forward to the next ChannelInboundHandler 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
    exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
    Calls ChannelHandlerContext.fireExceptionCaught(Throwable) to forward to the next ChannelHandler in the ChannelPipeline.
    void
    flush(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.flush() to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    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.
    protected final HttpRequestDecoder
    inboundHandler()
     
    protected final void
    init(HttpRequestDecoder inboundHandler, HttpResponseEncoder outboundHandler)
    Initialized this handler with the specified handlers.
    protected final HttpResponseEncoder
    outboundHandler()
     
    void
    read(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.read() to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    final void
    removeInboundHandler()
    Removes the ChannelInboundHandler that was combined in this CombinedChannelDuplexHandler.
    final void
    removeOutboundHandler()
    Removes the ChannelOutboundHandler that was combined in this CombinedChannelDuplexHandler.
    void
    userEventTriggered(ChannelHandlerContext ctx, Object evt)
    Calls ChannelHandlerContext.fireUserEventTriggered(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline.
    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 ChannelHandlerAdapter

    ensureNotSharable, isSharable
    Modifier and Type
    Method
    Description
    protected void
    ensureNotSharable()
    Throws IllegalStateException if ChannelHandlerAdapter.isSharable() returns true
    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

    • HttpServerCodec

      public HttpServerCodec()
      Creates a new instance with the default decoder options (maxInitialLineLength (4096), maxHeaderSize (8192), and maxChunkSize (8192)).
    • HttpServerCodec

      public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize)
      Creates a new instance with the specified decoder options.
    • HttpServerCodec

      @Deprecated public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders)
      Deprecated.
      Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
      Creates a new instance with the specified decoder options.
    • HttpServerCodec

      @Deprecated public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders, int initialBufferSize)
      Deprecated.
      Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
      Creates a new instance with the specified decoder options.
    • HttpServerCodec

      @Deprecated public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths)
      Deprecated.
      Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
      Creates a new instance with the specified decoder options.
    • HttpServerCodec

      @Deprecated public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders, int initialBufferSize, boolean allowDuplicateContentLengths, boolean allowPartialChunks)
      Deprecated.
      Prefer the HttpServerCodec(HttpDecoderConfig) constructor, to always enable header validation.
      Creates a new instance with the specified decoder options.
    • HttpServerCodec

      public HttpServerCodec(HttpDecoderConfig config)
      Creates a new instance with the specified decoder configuration.
    • HttpServerCodec

      public HttpServerCodec(HttpDecoderConfig config, int maxPipelineDepth)
      Creates a new instance with the specified decoder configuration.
      Parameters:
      config - the decoder configuration.
      maxPipelineDepth - the maximum number of requests that may be decoded while awaiting the corresponding responses to be written, before decoding of further requests is rejected with an IllegalStateException.
  • Method Details

    • upgradeFrom

      public void upgradeFrom(ChannelHandlerContext ctx)
      Upgrades to another protocol from HTTP. Removes the HttpRequestDecoder and HttpResponseEncoder from the pipeline.
      Specified by:
      upgradeFrom in interface HttpServerUpgradeHandler.SourceCodec
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.