Class HTTP2Stream

java.lang.Object
org.eclipse.jetty.http2.HTTP2Stream
All Implemented Interfaces:
Closeable, AutoCloseable, Stream, IStream, org.eclipse.jetty.io.CyclicTimeouts.Expirable, org.eclipse.jetty.util.Attachable, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.thread.Invocable

public class HTTP2Stream extends Object implements IStream, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.io.CyclicTimeouts.Expirable
  • Constructor Details

    • HTTP2Stream

      public HTTP2Stream(ISession session, int streamId, org.eclipse.jetty.http.MetaData.Request request, boolean local)
    • HTTP2Stream

      @Deprecated public HTTP2Stream(org.eclipse.jetty.util.thread.Scheduler scheduler, ISession session, int streamId, org.eclipse.jetty.http.MetaData.Request request, boolean local)
      Deprecated.
  • Method Details

    • getId

      public int getId()
      Specified by:
      getId in interface Stream
      Returns:
      the stream unique id
    • getAttachment

      public Object getAttachment()
      Specified by:
      getAttachment in interface org.eclipse.jetty.util.Attachable
    • setAttachment

      public void setAttachment(Object attachment)
      Specified by:
      setAttachment in interface org.eclipse.jetty.util.Attachable
    • isLocal

      public boolean isLocal()
      Specified by:
      isLocal in interface IStream
      Returns:
      whether this stream is local or remote
    • getSession

      public ISession getSession()
      Specified by:
      getSession in interface IStream
      Specified by:
      getSession in interface Stream
      Returns:
      the session this stream is associated to
    • headers

      public void headers(HeadersFrame frame, org.eclipse.jetty.util.Callback callback)
      Description copied from interface: Stream

      Sends the given HEADERS frame.

      Typically used to send an HTTP response or to send the HTTP response trailers.

      Specified by:
      headers in interface Stream
      Parameters:
      frame - the HEADERS frame to send
      callback - the callback that gets notified when the frame has been sent
    • send

      public void send(IStream.FrameList frameList, org.eclipse.jetty.util.Callback callback)
      Description copied from interface: IStream

      Sends the given list of frames.

      Typically used to send HTTP headers along with content and possibly trailers.

      Specified by:
      send in interface IStream
      Parameters:
      frameList - the list of frames to send
      callback - the callback that gets notified when the frames have been sent
    • push

      public void push(PushPromiseFrame frame, org.eclipse.jetty.util.Promise<Stream> promise, Stream.Listener listener)
      Description copied from interface: Stream

      Sends the given PUSH_PROMISE frame.

      Specified by:
      push in interface Stream
      Parameters:
      frame - the PUSH_PROMISE frame to send
      promise - the promise that gets notified of the pushed stream creation
      listener - the listener that gets notified of stream events
    • data

      public void data(DataFrame frame, org.eclipse.jetty.util.Callback callback)
      Description copied from interface: Stream

      Sends the given DATA frame.

      Specified by:
      data in interface Stream
      Parameters:
      frame - the DATA frame to send
      callback - the callback that gets notified when the frame has been sent
    • reset

      public void reset(ResetFrame frame, org.eclipse.jetty.util.Callback callback)
      Description copied from interface: Stream

      Sends the given RST_STREAM frame.

      Specified by:
      reset in interface Stream
      Parameters:
      frame - the RST_FRAME to send
      callback - the callback that gets notified when the frame has been sent
    • getAttribute

      public Object getAttribute(String key)
      Specified by:
      getAttribute in interface Stream
      Parameters:
      key - the attribute key
      Returns:
      an arbitrary object associated with the given key to this stream or null if no object can be found for the given key.
      See Also:
    • setAttribute

      public void setAttribute(String key, Object value)
      Specified by:
      setAttribute in interface Stream
      Parameters:
      key - the attribute key
      value - an arbitrary object to associate with the given key to this stream
      See Also:
    • removeAttribute

      public Object removeAttribute(String key)
      Specified by:
      removeAttribute in interface Stream
      Parameters:
      key - the attribute key
      Returns:
      the arbitrary object associated with the given key to this stream
      See Also:
    • isReset

      public boolean isReset()
      Specified by:
      isReset in interface Stream
      Returns:
      whether this stream has been reset
    • isResetOrFailed

      public boolean isResetOrFailed()
      Specified by:
      isResetOrFailed in interface IStream
      Returns:
      whether this stream has been reset (locally or remotely) or has been failed
      See Also:
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface Stream
      Returns:
      whether this stream is closed, both locally and remotely.
    • isRemotelyClosed

      public boolean isRemotelyClosed()
      Specified by:
      isRemotelyClosed in interface IStream
      Returns:
      whether the stream is closed remotely.
      See Also:
    • failAllData

      public boolean failAllData(Throwable x)
      Description copied from interface: IStream
      Fail all data queued in the stream and reset demand to 0.
      Specified by:
      failAllData in interface IStream
      Parameters:
      x - the exception to fail the data with.
      Returns:
      true if the end of the stream was reached, false otherwise.
    • isLocallyClosed

      public boolean isLocallyClosed()
    • commit

      public void commit()
      Description copied from interface: IStream
      Marks this stream as committed.
      Specified by:
      commit in interface IStream
      See Also:
    • isCommitted

      public boolean isCommitted()
      Specified by:
      isCommitted in interface IStream
      Returns:
      whether bytes for this stream have been sent to the remote peer.
      See Also:
    • dataSize

      public int dataSize()
      Specified by:
      dataSize in interface IStream
      Returns:
      the size of the DATA frame queue
    • isOpen

      public boolean isOpen()
    • notIdle

      public void notIdle()
      Description copied from interface: IStream

      Marks this stream as not idle so that the idle timeout is postponed.

      Specified by:
      notIdle in interface IStream
    • getExpireNanoTime

      public long getExpireNanoTime()
      Specified by:
      getExpireNanoTime in interface org.eclipse.jetty.io.CyclicTimeouts.Expirable
    • getIdleTimeout

      public long getIdleTimeout()
      Specified by:
      getIdleTimeout in interface Stream
      Returns:
      the stream idle timeout
      See Also:
    • setIdleTimeout

      public void setIdleTimeout(long idleTimeout)
      Specified by:
      setIdleTimeout in interface Stream
      Parameters:
      idleTimeout - the stream idle timeout
      See Also:
    • onIdleExpired

      protected void onIdleExpired(TimeoutException timeout)
    • getListener

      public Stream.Listener getListener()
      Specified by:
      getListener in interface IStream
      Returns:
      the Stream.Listener associated with this stream
      See Also:
    • setListener

      public void setListener(Stream.Listener listener)
      Specified by:
      setListener in interface IStream
      Parameters:
      listener - the Stream.Listener associated with this stream
      See Also:
    • process

      public void process(Frame frame, org.eclipse.jetty.util.Callback callback)
      Description copied from interface: IStream

      Processes the given frame, belonging to this stream.

      Specified by:
      process in interface IStream
      Parameters:
      frame - the frame to process
      callback - the callback to complete when frame has been processed
    • demand

      public void demand(long n)
      Description copied from interface: Stream

      Demands n more DATA frames for this stream.

      Specified by:
      demand in interface Stream
      Parameters:
      n - the increment of the demand, must be greater than zero
      See Also:
    • updateClose

      public boolean updateClose(boolean update, CloseState.Event event)
      Description copied from interface: IStream

      Updates the close state of this stream.

      Specified by:
      updateClose in interface IStream
      Parameters:
      update - whether to update the close state
      event - the event that caused the close state update
      Returns:
      whether the stream has been fully closed by this invocation
    • getSendWindow

      public int getSendWindow()
    • getRecvWindow

      public int getRecvWindow()
    • updateSendWindow

      public int updateSendWindow(int delta)
      Description copied from interface: IStream

      Updates the stream send window by the given delta.

      Specified by:
      updateSendWindow in interface IStream
      Parameters:
      delta - the delta value (positive or negative) to add to the stream send window
      Returns:
      the previous value of the stream send window
    • updateRecvWindow

      public int updateRecvWindow(int delta)
      Description copied from interface: IStream

      Updates the stream receive window by the given delta.

      Specified by:
      updateRecvWindow in interface IStream
      Parameters:
      delta - the delta value (positive or negative) to add to the stream receive window
      Returns:
      the previous value of the stream receive window
    • close

      public void close()
      Description copied from interface: IStream

      Forcibly closes this stream.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface IStream
    • onClose

      public void onClose()
    • succeeded

      public void succeeded()
      Specified by:
      succeeded in interface org.eclipse.jetty.util.Callback
    • failed

      public void failed(Throwable x)
      Specified by:
      failed in interface org.eclipse.jetty.util.Callback
    • getInvocationType

      public org.eclipse.jetty.util.thread.Invocable.InvocationType getInvocationType()
      Specified by:
      getInvocationType in interface org.eclipse.jetty.util.thread.Invocable
    • dump

      public String dump()
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object