Interface HTTPMessageStream

All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
HTTPClientStream, HTTPServerStream
All Known Implementing Classes:
AbstractHTTPClientStream, AbstractHTTPMessageStream, AbstractHTTPServerStream

public interface HTTPMessageStream extends Closeable
A HTTPMessageStream represents a single HTTP request transaction.
Since:
1.4.1
See Also:
  • Method Details

    • getRequest

      HTTPRequest getRequest()
      Returns the request of this HTTPMessageStream.
      Returns:
      The request
    • setReceiveData

      void setReceiveData(boolean receiveData)
      Sets whether this stream should continue receiving data.

      Disabling this will attempt to reduce or block incoming data passed to the data callback, if supported by the underlying protocol or transport.

      Parameters:
      receiveData - true to continue receiving data
    • onWritable

      void onWritable(Runnable onWritable)
      Sets a callback that is called when this HTTPMessageStream has cleared its write buffer after a sendData call returned false.
      Parameters:
      onWritable - The callback
    • onError

      void onError(Consumer<Exception> onError)
      Sets a callback that is called when this HTTPMessageStream encounters a fatal error. This includes exceptions thrown by other callback handlers. Usually, this HTTPMessageStream is closed after this callback is called.
      Parameters:
      onError - The callback
    • isClosed

      boolean isClosed()
      Returns true if this HTTPMessageStream has closed, either forcibly (via close()) or because the request transaction has completed.
      Returns:
      true if closed
    • close

      default void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • close

      Terminates this HTTPMessageStream at any time, causing no further callbacks to be called and the transaction with the peer to end abnormally.

      An optional reason can be specified in the closeReason parameter, which may be passed on to the peer, if supported by the underlying protocol.

      Calling this method after this HTTPMessageStream ended (successfully or abnormally) has no effects.

      Parameters:
      closeReason - An optional reason this message stream is being closed