Class Netty4HttpContentSizeHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.elasticsearch.http.netty4.Netty4HttpContentSizeHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class Netty4HttpContentSizeHandler extends io.netty.channel.ChannelInboundHandlerAdapter
Provides handling for 'Expect' header and content size. Implements HTTP1.1 spec. Allows Expect: 100-continue header only. Other 'Expect' headers will be rejected with 417 Expectation Failed reason.
Replies 100 Continue to requests with allowed maxContentLength.
Replies 413 Request Entity Too Large when content size exceeds maxContentLength. Channel can be reused for requests with "Expect:100-Continue" header that exceed allowed content length, as long as request does not include content. If oversized request already contains content then we cannot safely proceed and connection will be closed.

TODO: move to RestController to allow content limits per RestHandler. Ideally we should be able to handle Continue and oversized request in the RestController.
  • 100 Continue is interim response, means RestChannel will send 2 responses for a single request. See rfc9110.html#status.100
  • RestChannel should be able to close underlying HTTP channel connection.
  • Nested Class Summary

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

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

    Constructors
    Constructor
    Description
    Netty4HttpContentSizeHandler(io.netty.handler.codec.http.HttpRequestDecoder decoder, int maxContentLength)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

    • Netty4HttpContentSizeHandler

      public Netty4HttpContentSizeHandler(io.netty.handler.codec.http.HttpRequestDecoder decoder, int maxContentLength)
  • Method Details

    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter