Interface HttpStream

All Superinterfaces:
Callback, Invocable
All Known Implementing Classes:
CompletionStreamWrapper, HttpConnection.HttpStreamOverHTTP1, HttpStream.Wrapper, HttpStreamOverFCGI, HttpStreamOverHTTP2

public interface HttpStream extends 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.
  • Field Details

    • CONTENT_NOT_CONSUMED

      static final Exception 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

      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(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(MetaData.Request request, MetaData.Response response, boolean last, ByteBuffer content, 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.
    • push

      default void push(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()
    • consumeAvailable

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

      default Invocable.InvocationType getInvocationType()
      Specified by:
      getInvocationType in interface Invocable
      Returns:
      The InvocationType of this object