Class PacedLargeWriteHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.stream.ChunkedWriteHandler
org.mockserver.netty.unification.PacedLargeWriteHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

public class PacedLargeWriteHandler extends io.netty.handler.stream.ChunkedWriteHandler
Sends a large encoded HTTP/1.1 message to the socket in slices, writing the next slice only while the connection is writable. A slow reader then holds about one slice plus the connection's write-buffer high-water mark of outbound data, instead of the whole body: the transport copies a heap body into direct memory as it is written, so without this every slow reader pins a direct copy of its response.

It sits on the socket side of HttpServerCodec and sees encoded bytes, so the bytes on the wire are unchanged and anything written after a paced body - including raw bytes written from the codec's context - queues behind it in order. Only buffers written while the codec is in the pipeline are paced: after a WebSocket upgrade removes it, frames pass straight into the outbound buffer, where the WebSocket relay's writability-based backpressure can see them.

  • 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
    write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
     

    Methods inherited from class io.netty.handler.stream.ChunkedWriteHandler

    channelInactive, channelWritabilityChanged, flush, handlerAdded, handlerRemoved, resumeTransfer

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, read

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PacedLargeWriteHandler

      public PacedLargeWriteHandler()
  • Method Details

    • write

      public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.handler.stream.ChunkedWriteHandler
      Throws:
      Exception