Class Http2ResponseWriter

java.lang.Object
dev.relism.flash.http2.message.Http2ResponseWriter
All Implemented Interfaces:
WriteIntent, ResponseSerializer.FieldConsumer

public final class Http2ResponseWriter extends Object implements WriteIntent, ResponseSerializer.FieldConsumer
Reusable per-stream HTTP/2 response serializer. It prepares a complete small response outside the connection write lock and exposes it as one WriteIntent.
  • Constructor Details

    • Http2ResponseWriter

      public Http2ResponseWriter()
    • Http2ResponseWriter

      public Http2ResponseWriter(int initialHeaderCapacity, int initialOutputCapacity)
  • Method Details

    • completion

      public void completion(Http2ResponseWriter.Completion completion)
    • prepare

      public boolean prepare(Response response, int streamId, boolean headRequest, boolean sendDate, boolean sendContentLength, boolean huffmanDynamicValues, boolean emitTableSizeUpdate, int maxFrameSize, long maxHeaderListSize, int availableFlowWindow)
      Prepares a non-streaming response. Returns false when the body needs the deferred DATA flow-control path implemented by the stream scheduler.
    • startFlowControlled

      public int startFlowControlled(Response response, int streamId, boolean headRequest, boolean sendDate, boolean sendContentLength, boolean huffmanDynamicValues, boolean emitTableSizeUpdate, int maxFrameSize, long maxHeaderListSize, int availableFlowWindow) throws IOException
      Starts a response whose DATA may span multiple flow-control windows.
      Throws:
      IOException
    • resume

      public int resume(int maxFrameSize, int availableFlowWindow) throws IOException
      Serializes the next DATA batch after a WINDOW_UPDATE or previous write completion.
      Throws:
      IOException
    • finished

      public boolean finished()
    • headersInBatch

      public boolean headersInBatch()
    • endStreamInBatch

      public boolean endStreamInBatch()
    • dataBytesInBatch

      public int dataBytesInBatch()
    • trailerHeadersInBatch

      public boolean trailerHeadersInBatch()
    • accept

      public void accept(byte[] name, int nameOff, int nameLen, byte[] value, int valueOff, int valueLen)
      Specified by:
      accept in interface ResponseSerializer.FieldConsumer
    • buffer

      public byte[] buffer()
      Description copied from interface: WriteIntent
      The buffer holding this intent's already-serialized bytes.
      Specified by:
      buffer in interface WriteIntent
    • offset

      public int offset()
      Description copied from interface: WriteIntent
      Offset of the first byte to write, within WriteIntent.buffer().
      Specified by:
      offset in interface WriteIntent
    • length

      public int length()
      Description copied from interface: WriteIntent
      Number of bytes to write, starting at WriteIntent.offset().
      Specified by:
      length in interface WriteIntent
    • mpscNext

      public WriteIntent mpscNext()
      Description copied from interface: WriteIntent
      Intrusive MPSC queue linkage — see IntrusiveMpscQueue. Not for external use.
      Specified by:
      mpscNext in interface WriteIntent
    • setMpscNext

      public void setMpscNext(WriteIntent next)
      Description copied from interface: WriteIntent
      Intrusive MPSC queue linkage — see IntrusiveMpscQueue. Not for external use.
      Specified by:
      setMpscNext in interface WriteIntent
    • completed

      public void completed()
      Description copied from interface: WriteIntent
      Called exactly once after this intent leaves the writer, whether the socket write succeeded or failed. Pooled control-frame intents use this hook to return their slot to the owning connection without allocating a completion object.
      Specified by:
      completed in interface WriteIntent