Class ExpectContinueInboundHttp2ToHttpAdapter

java.lang.Object
io.netty.handler.codec.http2.Http2EventAdapter
io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter
org.mockserver.netty.proxy.relay.ExpectContinueInboundHttp2ToHttpAdapter
All Implemented Interfaces:
io.netty.handler.codec.http2.Http2Connection.Listener, io.netty.handler.codec.http2.Http2FrameListener

public class ExpectContinueInboundHttp2ToHttpAdapter extends io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter
The proxy client's side of the CONNECT/SOCKS relay's HTTP/2 tunnel, handing each request on once, with its whole body. Netty's InboundHttp2ToHttpAdapter hands a request carrying Expect on as soon as its headers arrive, with no body, then again with the body: MockServer answered the headers alone and never saw the body. Here the relay meets the expectation itself, as HttpObjectAggregator does on MockServer's own HTTP/2 streams and on an HTTP/1.1 tunnel, and removes the Expect header, so MockServer does not answer it again:
  • 100-continue with no content-length over maxContentLength: a 100 response, then the request is handed on when its body is complete;
  • 100-continue with a larger content-length: 413, and the request is not handed on;
  • any other expectation: 417, and the request is not handed on.
After a 413 or 417 the stream is reset with NO_ERROR, so the client stops uploading (RFC 9113 section 8.1). The reset is also what keeps the tunnel up: DATA still arriving on a stream left open would reach the adapter with no request to add it to, a connection error. A request whose headers end the stream is complete already, so is handed on as it is, Expect included, as HttpObjectAggregator passes on a request that needs no aggregation.
  • Field Summary

    Fields inherited from class io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter

    connection, validateHttpHeaders
  • Method Summary

    Modifier and Type
    Method
    Description
    forConnection(io.netty.handler.codec.http2.Http2Connection connection, int maxContentLength)
    An adapter listening to the connection, as Netty's builder makes one: a request still being uploaded is released when its stream is removed.
    protected io.netty.handler.codec.http.FullHttpMessage
    processHeadersBegin(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http2.Http2Stream stream, io.netty.handler.codec.http2.Http2Headers headers, boolean endOfStream, boolean allowAppend, boolean appendToTrailer)
     

    Methods inherited from class io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter

    fireChannelRead, getMessage, newMessage, onDataRead, onHeadersRead, onHeadersRead, onPushPromiseRead, onRstStreamRead, onRstStreamRead, onSettingsRead, onStreamRemoved, putMessage, removeMessage

    Methods inherited from class io.netty.handler.codec.http2.Http2EventAdapter

    onGoAwayRead, onGoAwayReceived, onGoAwaySent, onPingAckRead, onPingRead, onPriorityRead, onSettingsAckRead, onStreamActive, onStreamAdded, onStreamClosed, onStreamHalfClosed, onUnknownFrame, onWindowUpdateRead

    Methods inherited from class java.lang.Object

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

    • forConnection

      public static ExpectContinueInboundHttp2ToHttpAdapter forConnection(io.netty.handler.codec.http2.Http2Connection connection, int maxContentLength)
      An adapter listening to the connection, as Netty's builder makes one: a request still being uploaded is released when its stream is removed.
    • processHeadersBegin

      protected io.netty.handler.codec.http.FullHttpMessage processHeadersBegin(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http2.Http2Stream stream, io.netty.handler.codec.http2.Http2Headers headers, boolean endOfStream, boolean allowAppend, boolean appendToTrailer) throws io.netty.handler.codec.http2.Http2Exception
      Overrides:
      processHeadersBegin in class io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter
      Throws:
      io.netty.handler.codec.http2.Http2Exception