Class QuicStreamMessage

java.lang.Object
org.microproxy.quic.QuicStreamMessage

public final class QuicStreamMessage extends Object
Bytes the proxy read from one side of a stream of an intercepted QUIC connection, as a QuicInterceptor sees them.

A QUIC stream is a byte stream, not a sequence of messages: a message is whatever one read returned (at most 16 KiB), so the peer's writes may arrive split into several messages or joined into one, differently from one run to the next. A hook that looks for a message of the protocol must allow for it starting in one message and ending in the next.

  • Constructor Details

    • QuicStreamMessage

      public QuicStreamMessage(byte[] data, boolean fromClient, Instant timestamp)
      A message.
      Parameters:
      data - the bytes, which the message holds as they are (not copied)
      fromClient - whether the client sent them, rather than the server
      timestamp - when the proxy read them
  • Method Details

    • data

      public byte[] data()
      The bytes as read. The array is the message's own, not a copy: an interceptor may change it in place and return it.
      Returns:
      the bytes
    • length

      public int length()
      Returns the number of bytes.
      Returns:
      the number of bytes
    • fromClient

      public boolean fromClient()
      Returns whether the client sent the bytes (going to the server), rather than the server.
      Returns:
      whether the client sent the bytes (going to the server), rather than the server
    • timestamp

      public Instant timestamp()
      Returns when the proxy read the bytes.
      Returns:
      when the proxy read the bytes
    • text

      public String text()
      The bytes decoded as UTF-8, malformed sequences replaced with U+FFFD. A character split between two messages shows as replacement characters in both.
      Returns:
      the text
    • withData

      public QuicStreamMessage withData(byte[] data)
      A copy of this message with other bytes, the same direction and timestamp.
      Parameters:
      data - the bytes of the copy (not copied)
      Returns:
      the copy
    • withText

      public QuicStreamMessage withText(String text)
      A copy of this message with the UTF-8 encoding of text.
      Parameters:
      text - the text of the copy
      Returns:
      the copy
    • toString

      public String toString()
      Overrides:
      toString in class Object