Class TimeToFirstByteHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.mockserver.httpclient.TimeToFirstByteHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class TimeToFirstByteHandler extends io.netty.channel.ChannelInboundHandlerAdapter
Records the wall-clock time when the first inbound byte (response head) arrives from the upstream server. This handler fires once on the first channelRead and then removes itself from the pipeline so subsequent reads pay zero overhead.

The timestamp is stored in the channel attribute FIRST_BYTE_MILLIS so that NettyHttpClient can compute timeToFirstByteInMillis when building the Timing object.

Extends ChannelInboundHandlerAdapter (not SimpleChannelInboundHandler) to avoid auto-release of the proxied message. A firstByte value of 0 means "not captured".

  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

    • TimeToFirstByteHandler

      public TimeToFirstByteHandler()
  • Method Details

    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception