Package org.mockserver.netty.unification
Class Http2RequestHeaderLimit
java.lang.Object
org.mockserver.netty.unification.Http2RequestHeaderLimit
Limits the header list of an HTTP/2 request to
maxHeaderSize, as HTTP/1.1 limits its header section, and
logs each request refused for it. The limit is counted as HTTP/2 defines it (RFC 9113 section 6.5.2): every field's
name and value, the pseudo-header fields included, plus 32 bytes a field, after HPACK decoding.
Netty enforces it: a header list over the limit is answered 431 and its stream reset, and a header block
of more than the limit plus a quarter closes the connection with GOAWAY. Neither reaches a handler, so the
codecs built here log them as they are raised.
A request's trailers are limited as its headers are, and only reset their stream: the request is not dispatched,
and a response being sent stops. A tunnel answers 431 first if no response has started; a direct
connection hands the error to the stream's own pipeline, where LenientInboundHttp2StreamFrameCodec stops it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.handler.codec.http2.Http2FrameCodecBuilderframeCodecBuilder(org.mockserver.logging.MockServerLogger mockServerLogger) static booleanisRefusedRequestCutShort(io.netty.channel.Channel stream, Throwable cause) Whethercauseis the aggregator reporting the part of a request it held when the stream was reset for its trailers: expected, and already logged as the refusal, so not worth logging again.static io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerrelayLoopbackHandler(org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.handler.codec.http2.Http2Connection connection, io.netty.handler.codec.http2.Http2FrameListener frameListener, io.netty.handler.codec.http2.Http2FrameLogger frameLogger) static io.netty.handler.codec.http2.Http2Settingsstatic io.netty.handler.codec.http2.Http2SettingsserverSettings(org.mockserver.configuration.Configuration configuration) static io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlertunnelServerHandler(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.handler.codec.http2.Http2Connection connection, io.netty.handler.codec.http2.Http2FrameListener frameListener, io.netty.handler.codec.http2.Http2FrameLogger frameLogger, boolean addedWhileReading)
-
Method Details
-
serverSettings
public static io.netty.handler.codec.http2.Http2Settings serverSettings(org.mockserver.configuration.Configuration configuration) - Returns:
- Netty's default settings with
SETTINGS_MAX_HEADER_LIST_SIZEset tomaxHeaderSize
-
relayLoopbackSettings
public static io.netty.handler.codec.http2.Http2Settings relayLoopbackSettings()- Returns:
- the settings of both ends of the loopback leg of a CONNECT or SOCKS tunnel, which set no header list limit. Its requests were limited on the tunnel's client leg and the relay has since added fields to them, so limiting them again would refuse a request the client was told is within the limit; its responses are MockServer's own
-
relayLoopbackHandler
public static io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler relayLoopbackHandler(org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.handler.codec.http2.Http2Connection connection, io.netty.handler.codec.http2.Http2FrameListener frameListener, io.netty.handler.codec.http2.Http2FrameLogger frameLogger) - Returns:
- the client handler of the loopback leg of a CONNECT or SOCKS tunnel carrying HTTP/2, built as Netty's
HttpToHttp2ConnectionHandlerBuilderbuilds it withrelayLoopbackSettings(), except that it sends nox-http2-extension header a request read from the proxy client carries, and that it logs a connection error it closes the loopback for
-
frameCodecBuilder
public static io.netty.handler.codec.http2.Http2FrameCodecBuilder frameCodecBuilder(org.mockserver.logging.MockServerLogger mockServerLogger) - Returns:
- a server
Http2FrameCodecBuilderwhose codec logs the requests it refuses for their header size
-
tunnelServerHandler
public static io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler tunnelServerHandler(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.handler.codec.http2.Http2Connection connection, io.netty.handler.codec.http2.Http2FrameListener frameListener, io.netty.handler.codec.http2.Http2FrameLogger frameLogger, boolean addedWhileReading) - Parameters:
addedWhileReading- whether the handler is added while the client's bytes are being read, so that the read'schannelReadCompleteflushes itsSETTINGSonce they are decoded; otherwise they are flushed as the handler is added- Returns:
- the server handler of a CONNECT or SOCKS tunnel carrying HTTP/2, which logs the requests it refuses for their header size
-
isRefusedRequestCutShort
Whethercauseis the aggregator reporting the part of a request it held when the stream was reset for its trailers: expected, and already logged as the refusal, so not worth logging again.
-