Package org.mockserver.httpclient
Class StreamingResponseRelayHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- org.mockserver.httpclient.StreamingResponseRelayHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class StreamingResponseRelayHandler extends io.netty.channel.ChannelInboundHandlerAdapterConsumes unaggregatedHttpObjects on theNettyHttpClientchannel when a streaming response is detected. On the response head it builds a head-onlyHttpResponsewith aStreamingBodyand completes the channel'sRESPONSE_FUTUREimmediately so the caller can start relaying chunks to the proxy client without waiting for the entire body.On each
HttpContentchunk, the bytes are fed to theStreamingBody(bounded capture + forward). OnLastHttpContent, the body is completed and the channel is closed. OnchannelInactiveor exception mid-stream the body is errored so the log entry can still be written with whatever was captured.
-
-
Constructor Summary
Constructors Constructor Description StreamingResponseRelayHandler(Configuration configuration, MockServerLogger mockServerLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Constructor Detail
-
StreamingResponseRelayHandler
public StreamingResponseRelayHandler(Configuration configuration, MockServerLogger mockServerLogger)
-
-
Method Detail
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
-