Class HTTP3Stream

java.lang.Object
org.eclipse.jetty.http3.HTTP3Stream
All Implemented Interfaces:
Stream, CyclicTimeouts.Expirable, Attachable
Direct Known Subclasses:
HTTP3StreamClient

public abstract class HTTP3Stream extends Object implements Stream, CyclicTimeouts.Expirable, Attachable
  • Constructor Details

  • Method Details

    • getEndPoint

      public QuicStreamEndPoint getEndPoint()
    • getAttachment

      public Object getAttachment()
      Specified by:
      getAttachment in interface Attachable
      Returns:
      the object attached to this instance
      See Also:
    • setAttachment

      public void setAttachment(Object attachment)
      Description copied from interface: Attachable
      Attaches the given object to this stream for later retrieval.
      Specified by:
      setAttachment in interface Attachable
      Parameters:
      attachment - the object to attach to this instance
    • getId

      public long getId()
      Description copied from interface: Stream
      Get the stream id.
      Specified by:
      getId in interface Stream
      Returns:
      the stream id
    • getSession

      public HTTP3Session getSession()
      Description copied from interface: Stream
      Get the session this stream is associated to.
      Specified by:
      getSession in interface Stream
      Returns:
      the session this stream is associated to
    • isLocal

      public boolean isLocal()
    • getIdleTimeout

      public long getIdleTimeout()
    • setIdleTimeout

      public void setIdleTimeout(long idleTimeout)
    • getExpireNanoTime

      public long getExpireNanoTime()
      Description copied from interface: CyclicTimeouts.Expirable

      Returns the expiration time in nanoseconds.

      The value to return must be calculated taking into account the current nanoTime, for example:

      expireNanoTime = NanoTime.now() + timeoutNanos

      Returning Long.MAX_VALUE indicates that this entity does not expire.

      Specified by:
      getExpireNanoTime in interface CyclicTimeouts.Expirable
      Returns:
      the expiration time in nanoseconds, or Long.MAX_VALUE if this entity does not expire
    • notIdle

      protected void notIdle()
    • data

      public CompletableFuture<Stream> data(DataFrame frame)
      Description copied from interface: Stream

      Sends the given DATA frame containing some or all the bytes of the request content or of the response content.

      Specified by:
      data in interface Stream
      Parameters:
      frame - the DATA frame containing some or all the bytes of the request or of the response.
      Returns:
      the CompletableFuture that gets notified when the frame has been sent
    • write

      protected CompletableFuture<Stream> write(Frame frame)
    • readData

      public Stream.Data readData()
      Description copied from interface: Stream

      Reads request content bytes or response content bytes.

      The returned Stream.Data object may be null, indicating that the end of the read side of the stream has not yet been reached, which may happen in these cases:

      • not all the bytes have been received so far, for example the remote peer did not send them yet, or they are in-flight
      • all the bytes have been received, but there is a trailer HEADERS frame to be received to indicate the end of the read side of the stream

      When the returned Stream.Data object is not null, applications must call, either immediately or later (possibly asynchronously) Retainable.release() to notify the implementation that the bytes have been processed.

      Stream.Data objects may be stored away for later, asynchronous, processing (for example, to process them only when all of them have been received).

      Specified by:
      readData in interface Stream
      Returns:
      a Stream.Data object containing the request bytes or the response bytes, or null if no bytes are available
      See Also:
    • demand

      public void demand()
      Description copied from interface: Stream

      Demands more DATA frames for this stream.

      Calling this method causes Stream.Client.Listener.onDataAvailable(Stream.Client) on the client, or Stream.Server.Listener.onDataAvailable(Stream.Server) on the server, to be invoked, possibly at a later time, when the stream has data to be read, but also when the stream has reached EOF.

      This method is idempotent: calling it when there already is an outstanding demand to invoke onDataAvailable(Stream) is a no-operation.

      The thread invoking this method may invoke directly onDataAvailable(Stream), unless another thread that must invoke onDataAvailable(Stream) notices the outstanding demand first.

      It is always guaranteed that invoking this method from within onDataAvailable(Stream) will not cause a StackOverflowError.

      Specified by:
      demand in interface Stream
      See Also:
    • trailer

      public CompletableFuture<Stream> trailer(HeadersFrame frame)
      Description copied from interface: Stream

      Sends the given HEADERS frame containing the trailer headers.

      Specified by:
      trailer in interface Stream
      Parameters:
      frame - the HEADERS frame containing the trailer headers
      Returns:
      the CompletableFuture that gets notified when the frame has been sent
    • hasDemand

      public boolean hasDemand()
    • onHeaders

      public void onHeaders(HeadersFrame frame)
    • hasDemandOrStall

      protected boolean hasDemandOrStall()
    • onData

      public void onData(DataFrame ignored)
    • onData

      public void onData(Stream.Data data)
    • notifyDataAvailable

      protected abstract void notifyDataAvailable()
    • onTrailer

      public void onTrailer(HeadersFrame frame)
    • notifyTrailer

      protected abstract void notifyTrailer(HeadersFrame frame)
    • notifyIdleTimeout

      protected abstract void notifyIdleTimeout(TimeoutException timeout, Promise<Boolean> promise)
    • onFailure

      public void onFailure(long error, Throwable failure)
    • notifyFailure

      protected abstract void notifyFailure(long error, Throwable failure)
    • validateAndUpdate

      protected boolean validateAndUpdate(EnumSet<HTTP3Stream.FrameState> allowed, HTTP3Stream.FrameState target)
    • writeFrame

      public Promise.Completable<Stream> writeFrame(Frame frame)
    • isClosed

      public boolean isClosed()
    • updateClose

      public void updateClose(boolean update, boolean local)
    • reset

      public void reset(long error, Throwable failure)
      Description copied from interface: Stream

      Abruptly terminates this stream with the given error.

      Specified by:
      reset in interface Stream
      Parameters:
      error - the error code
      failure - the failure that caused the reset of the stream
    • toString

      public String toString()
      Overrides:
      toString in class Object