Package org.mockserver.netty.unification
Class HttpServerCodecResponsePairing
java.lang.Object
org.mockserver.netty.unification.HttpServerCodecResponsePairing
Keeps
HttpServerCodec pairing each response with the request it answers when an exchange ends without its
response passing the codec's encoder. The codec queues each request's method as it decodes the request and takes
the oldest off as it encodes a final response, which it encodes for that method (no body for HEAD).
A response written as raw bytes beneath the codec (ResponseWrittenBeneathCodecEvent), no response, or a
final 1xx (HttpExchangeEndedEvent.INSTANCE) takes none off, so every later response would be
encoded for the method of the request before its own.
The codec is final and its queue private, so on each of those events the handler after the
codec has it encode an empty response of its own, which takes the entry off, and the handler
before the codec writes an empty buffer in place of what the encoder wrote, with the same
promise: nothing reaches the client, and a close the codec chains on that write still follows what came before.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.netty.channel.ChannelHandlerThe handler to add immediately after the HTTP server codec.io.netty.channel.ChannelHandlerThe handler to add immediately before the HTTP server codec.static io.netty.channel.ChannelHandlerContextbeneathCodec(io.netty.channel.ChannelPipeline pipeline) Where to add a handler that must see what is written from beneath the codec, raw bytes and encoded responses alike, but not the stand-in responses: before this pairing's handler before the codec, or the codec if it has none.static voidremoveFrom(io.netty.channel.ChannelPipeline pipeline) Removes both handlers, if present, for when the connection stops carrying HTTP/1.1 (a CONNECT or SOCKS tunnel).
-
Constructor Details
-
HttpServerCodecResponsePairing
public HttpServerCodecResponsePairing()
-
-
Method Details
-
beforeCodec
public io.netty.channel.ChannelHandler beforeCodec()The handler to add immediately before the HTTP server codec. -
afterCodec
public io.netty.channel.ChannelHandler afterCodec()The handler to add immediately after the HTTP server codec. -
beneathCodec
public static io.netty.channel.ChannelHandlerContext beneathCodec(io.netty.channel.ChannelPipeline pipeline) Where to add a handler that must see what is written from beneath the codec, raw bytes and encoded responses alike, but not the stand-in responses: before this pairing's handler before the codec, or the codec if it has none. Null if the pipeline has no codec. -
removeFrom
public static void removeFrom(io.netty.channel.ChannelPipeline pipeline) Removes both handlers, if present, for when the connection stops carrying HTTP/1.1 (a CONNECT or SOCKS tunnel).
-