Class BasicHttpClientCodec

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler, io.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec

    public final class BasicHttpClientCodec
    extends io.netty.channel.CombinedChannelDuplexHandler<BasicHttpResponseDecoder,​io.netty.handler.codec.http.HttpRequestEncoder>
    implements io.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec
    A combination of HttpRequestEncoder and BasicHttpResponseDecoder which enables easier client side HTTP implementation. HttpClientCodec provides additional state management for HEAD and CONNECT requests, which BasicHttpResponseDecoder lacks. Please refer to BasicHttpResponseDecoder to learn what additional state management needs to be done for HEAD and CONNECT and why BasicHttpResponseDecoder can not handle it by itself. If the Channel is closed and there are missing responses, a PrematureChannelClosureException is thrown.
    See Also:
    BasicHttpServerCodec
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicHttpClientCodec()
      Creates a new instance with the default decoder options (maxInitialLineLength (4096}, maxHeaderSize (8192), and maxChunkSize (8192)).
      BasicHttpClientCodec​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize)
      Creates a new instance with the specified decoder options.
      BasicHttpClientCodec​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse)
      Creates a new instance with the specified decoder options.
      BasicHttpClientCodec​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders)
      Creates a new instance with the specified decoder options.
      BasicHttpClientCodec​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, boolean parseHttpAfterConnectRequest)
      Creates a new instance with the specified decoder options.
      BasicHttpClientCodec​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize)
      Creates a new instance with the specified decoder options.
      BasicHttpClientCodec​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, boolean validateHeaders, int initialBufferSize, boolean parseHttpAfterConnectRequest)
      Creates a new instance with the specified decoder options.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isSingleDecode()  
      void prepareUpgradeFrom​(io.netty.channel.ChannelHandlerContext ctx)
      Prepares to upgrade to another protocol from HTTP.
      void setSingleDecode​(boolean singleDecode)  
      void upgradeFrom​(io.netty.channel.ChannelHandlerContext ctx)
      Upgrades to another protocol from HTTP.
      • Methods inherited from class io.netty.channel.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
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, isSharable
      • Methods inherited from class java.lang.Object

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

      • BasicHttpClientCodec

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

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

        public BasicHttpClientCodec​(int maxInitialLineLength,
                                    int maxHeaderSize,
                                    int maxChunkSize,
                                    boolean failOnMissingResponse)
        Creates a new instance with the specified decoder options.
      • BasicHttpClientCodec

        public BasicHttpClientCodec​(int maxInitialLineLength,
                                    int maxHeaderSize,
                                    int maxChunkSize,
                                    boolean failOnMissingResponse,
                                    boolean validateHeaders)
        Creates a new instance with the specified decoder options.
      • BasicHttpClientCodec

        public BasicHttpClientCodec​(int maxInitialLineLength,
                                    int maxHeaderSize,
                                    int maxChunkSize,
                                    boolean failOnMissingResponse,
                                    boolean validateHeaders,
                                    boolean parseHttpAfterConnectRequest)
        Creates a new instance with the specified decoder options.
      • BasicHttpClientCodec

        public BasicHttpClientCodec​(int maxInitialLineLength,
                                    int maxHeaderSize,
                                    int maxChunkSize,
                                    boolean failOnMissingResponse,
                                    boolean validateHeaders,
                                    int initialBufferSize)
        Creates a new instance with the specified decoder options.
      • BasicHttpClientCodec

        public BasicHttpClientCodec​(int maxInitialLineLength,
                                    int maxHeaderSize,
                                    int maxChunkSize,
                                    boolean failOnMissingResponse,
                                    boolean validateHeaders,
                                    int initialBufferSize,
                                    boolean parseHttpAfterConnectRequest)
        Creates a new instance with the specified decoder options.
    • Method Detail

      • prepareUpgradeFrom

        public void prepareUpgradeFrom​(io.netty.channel.ChannelHandlerContext ctx)
        Prepares to upgrade to another protocol from HTTP. Disables the HttpRequestEncoder.
        Specified by:
        prepareUpgradeFrom in interface io.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec
      • upgradeFrom

        public void upgradeFrom​(io.netty.channel.ChannelHandlerContext ctx)
        Upgrades to another protocol from HTTP. Removes the BasicHttpResponseDecoder and HttpRequestEncoder from the pipeline.
        Specified by:
        upgradeFrom in interface io.netty.handler.codec.http.HttpClientUpgradeHandler.SourceCodec
      • setSingleDecode

        public void setSingleDecode​(boolean singleDecode)
      • isSingleDecode

        public boolean isSingleDecode()