Package org.mockserver.netty.proxy.relay
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-continuewith nocontent-lengthovermaxContentLength: a100response, then the request is handed on when its body is complete;100-continuewith a largercontent-length:413, and the request is not handed on;- any other expectation:
417, and the request is not handed on.
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 TypeMethodDescriptionforConnection(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.FullHttpMessageprocessHeadersBegin(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, removeMessageMethods inherited from class io.netty.handler.codec.http2.Http2EventAdapter
onGoAwayRead, onGoAwayReceived, onGoAwaySent, onPingAckRead, onPingRead, onPriorityRead, onSettingsAckRead, onStreamActive, onStreamAdded, onStreamClosed, onStreamHalfClosed, onUnknownFrame, onWindowUpdateRead
-
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:
processHeadersBeginin classio.netty.handler.codec.http2.InboundHttp2ToHttpAdapter- Throws:
io.netty.handler.codec.http2.Http2Exception
-