Interface HttpStream

All Superinterfaces:
org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.thread.Invocable
All Known Implementing Classes:
HttpStream.Wrapper

public interface HttpStream extends org.eclipse.jetty.util.Callback
A HttpStream is an abstraction that together with MetaData.Request, represents the flow of data from and to a single request and response cycle. It is roughly analogous to the Stream within an HTTP/2 connection, in that a connection can have many streams, each used once and each representing a single request and response exchange.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
     

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Callback

    org.eclipse.jetty.util.Callback.Combination, org.eclipse.jetty.util.Callback.Completable, org.eclipse.jetty.util.Callback.Completing, org.eclipse.jetty.util.Callback.Nested

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable

    org.eclipse.jetty.util.thread.Invocable.Callable, org.eclipse.jetty.util.thread.Invocable.InvocationType, org.eclipse.jetty.util.thread.Invocable.ReadyTask, org.eclipse.jetty.util.thread.Invocable.Task
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Throwable
     
    static final String
    Attribute name to be used as a Request attribute to store/retrieve the Connection created during the HTTP/1.1 upgrade mechanism or the HTTP/2 tunnel mechanism.

    Fields inherited from interface org.eclipse.jetty.util.Callback

    NOOP, NOT_CALLED

    Fields inherited from interface org.eclipse.jetty.util.thread.Invocable

    __nonBlocking
  • Method Summary

    Modifier and Type
    Method
    Description
    cancelSend(Throwable cause, org.eclipse.jetty.util.Callback appCallback)
    Consume all content currently available.
    static Throwable
     
    void
    Demands more content chunks to the underlying implementation.
     
    long
     
    default org.eclipse.jetty.util.thread.Invocable.InvocationType
     
     
    boolean
     
    void
    prepareResponse(org.eclipse.jetty.http.HttpFields.Mutable headers)
    Prepare the response headers with respect to the stream.
    default void
    push(org.eclipse.jetty.http.MetaData.Request resource)
    Pushes the given resource to the client.
    org.eclipse.jetty.io.Content.Chunk
    Reads a chunk of content, with the same semantic as Content.Source.read().
    void
    send(org.eclipse.jetty.http.MetaData.Request request, org.eclipse.jetty.http.MetaData.Response response, boolean last, ByteBuffer content, org.eclipse.jetty.util.Callback callback)
    Send response meta-data and/or data.
    void
    setIdleTimeout(long idleTimeoutMs)
     

    Methods inherited from interface org.eclipse.jetty.util.Callback

    completeWith, failed, succeeded
  • Field Details

    • CONTENT_NOT_CONSUMED

      static final Throwable CONTENT_NOT_CONSUMED
    • UPGRADE_CONNECTION_ATTRIBUTE

      static final String UPGRADE_CONNECTION_ATTRIBUTE

      Attribute name to be used as a Request attribute to store/retrieve the Connection created during the HTTP/1.1 upgrade mechanism or the HTTP/2 tunnel mechanism.

  • Method Details

    • getId

      String getId()
      Returns:
      an ID unique within the lifetime scope of the associated protocol connection. This may be a protocol ID (e.g. HTTP/2 stream ID) or it may be unrelated to the protocol.
    • read

      org.eclipse.jetty.io.Content.Chunk read()

      Reads a chunk of content, with the same semantic as Content.Source.read().

      This method is called from the implementation of Request.read().

      Returns:
      a chunk of content, possibly with non-null Content.Chunk.getFailure() or null.
    • demand

      void demand()

      Demands more content chunks to the underlying implementation.

      This method is called from the implementation of Request.demand(Runnable) and when the demand can be satisfied the implementation must call HttpChannel.onContentAvailable(). If there is a problem meeting demand, then the implementation must call HttpChannel.onFailure(Throwable).

      See Also:
    • prepareResponse

      void prepareResponse(org.eclipse.jetty.http.HttpFields.Mutable headers)

      Prepare the response headers with respect to the stream. Typically this may set headers related to protocol specific behaviour (e.g. Keep-Alive for HTTP/1.0 connections).

      Parameters:
      headers - The headers to prepare.
    • send

      void send(org.eclipse.jetty.http.MetaData.Request request, org.eclipse.jetty.http.MetaData.Response response, boolean last, ByteBuffer content, org.eclipse.jetty.util.Callback callback)

      Send response meta-data and/or data.

      Parameters:
      request - The request metadata for which the response should be sent.
      response - The response metadata to be sent or null if the response is already committed by a previous call to send.
      last - True if this will be the last call to send and the response can be completed.
      content - A buffer of content to send or null if no content.
      callback - The callback to invoke when the send is completed successfully or in failure.
    • cancelSend

      Runnable cancelSend(Throwable cause, org.eclipse.jetty.util.Callback appCallback)
      Parameters:
      cause - The cause of the cancellation
      appCallback - The callback to ultimately fail after the cancellation
      Returns:
      A Runnable that will be run to complete the cancellation and will, in turn, ultimately fail both the passed Callback and any Callback that was passed to the send(MetaData.Request, MetaData.Response, boolean, ByteBuffer, Callback) method.
    • push

      default void push(org.eclipse.jetty.http.MetaData.Request resource)

      Pushes the given resource to the client.

      Parameters:
      resource - the resource to push
      Throws:
      UnsupportedOperationException - if the push functionality is not supported
      See Also:
    • getIdleTimeout

      long getIdleTimeout()
    • setIdleTimeout

      void setIdleTimeout(long idleTimeoutMs)
    • isCommitted

      boolean isCommitted()
    • getTunnelSupport

      default TunnelSupport getTunnelSupport()
    • consumeAvailable

      Throwable consumeAvailable()
      Consume all content currently available. If not all content could be consumed, the underlying connection may be made non-persistent.
      Returns:
      null if all content could be consumed, any Throwable instance otherwise.
    • consumeAvailable

      static Throwable consumeAvailable(HttpStream stream, HttpConfiguration httpConfig)
    • getInvocationType

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