Class StreamAddressedHttpContent

java.lang.Object
io.netty.handler.codec.http.DefaultHttpObject
io.netty.handler.codec.http.DefaultHttpContent
org.mockserver.codec.StreamAddressedHttpContent
All Implemented Interfaces:
io.netty.buffer.ByteBufHolder, io.netty.handler.codec.DecoderResultProvider, io.netty.handler.codec.http.HttpContent, io.netty.handler.codec.http.HttpObject, io.netty.util.ReferenceCounted

public final class StreamAddressedHttpContent extends io.netty.handler.codec.http.DefaultHttpContent
An HttpContent chunk that carries two pieces of out-of-band state for a streaming HTTP/2 response: whether the frame ends the stream, and (historically) the stream id it belongs to.

MockServer's HTTP/2 server pipeline gives every stream its own Http2MultiplexHandler child channel, so a streaming response is written on the channel that is that stream and no per-chunk stream id is needed to route it — the streamId field is therefore redundant on the current path and retained only for callers that still supply it.

The endStream flag is what still matters. A bare HttpContent/LastHttpContent frame reaches Http2StreamFrameToHttpObjectCodec, whose bare-HttpContent branch hard-codes endStream=false; the terminal frame's end-of-stream would be silently dropped and an SSE/NDJSON/AWS-event-stream client would receive every event and then hang until it times out (GitHub issue #2667 / #2669 follow-up). This wrapper carries the flag out-of-band so StreamAddressedContentHandler on the child channel can translate it into the HttpObject subtype the codec maps to an END_STREAM DATA frame.

It is deliberately a plain HttpContent (not an HttpMessage and not a LastHttpContent) so it passes untouched through the intervening outbound handlers (TraceContextHandler, MockServerHttpServerCodec's response encoder, the WebSocket handlers) — none of which inspect HttpContent — and reaches StreamAddressedContentHandler intact.

  • Constructor Summary

    Constructors
    Constructor
    Description
    StreamAddressedHttpContent(io.netty.buffer.ByteBuf content, int streamId, boolean endStream)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    io.netty.handler.codec.http.HttpContent
    replace(io.netty.buffer.ByteBuf content)
     
    int
     

    Methods inherited from class io.netty.handler.codec.http.DefaultHttpContent

    content, copy, duplicate, refCnt, release, release, retain, retain, retainedDuplicate, toString, touch, touch

    Methods inherited from class io.netty.handler.codec.http.DefaultHttpObject

    decoderResult, equals, getDecoderResult, hashCode, setDecoderResult

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.netty.handler.codec.DecoderResultProvider

    decoderResult, setDecoderResult

    Methods inherited from interface io.netty.handler.codec.http.HttpObject

    getDecoderResult
  • Constructor Details

    • StreamAddressedHttpContent

      public StreamAddressedHttpContent(io.netty.buffer.ByteBuf content, int streamId, boolean endStream)
      Parameters:
      content - the chunk payload (may be an empty buffer for a terminal END_STREAM frame)
      streamId - the HTTP/2 stream the chunk must be written on (the request's stream id)
      endStream - whether this frame ends the stream (true only for the terminal frame)
  • Method Details

    • streamId

      public int streamId()
    • endStream

      public boolean endStream()
    • replace

      public io.netty.handler.codec.http.HttpContent replace(io.netty.buffer.ByteBuf content)
      Specified by:
      replace in interface io.netty.buffer.ByteBufHolder
      Specified by:
      replace in interface io.netty.handler.codec.http.HttpContent
      Overrides:
      replace in class io.netty.handler.codec.http.DefaultHttpContent