Class AbstractHTTPMessageStream

java.lang.Object
org.omegazero.http.util.AbstractHTTPMessageStream
All Implemented Interfaces:
Closeable, AutoCloseable, HTTPMessageStream
Direct Known Subclasses:
AbstractHTTPClientStream, AbstractHTTPServerStream

public abstract class AbstractHTTPMessageStream extends Object implements HTTPMessageStream
A HTTPMessageStream with several basic methods implemented.
Since:
1.4.1
  • Field Details

  • Constructor Details

    • AbstractHTTPMessageStream

      public AbstractHTTPMessageStream(HTTPRequest request)
      Creates a new AbstractHTTPMessageStream.
      Parameters:
      request - The request
  • Method Details

    • internalError

      protected void internalError(Exception e)
      Called when a callback handler throws an exception. Calls the onError callback and closes this stream with reason INTERNAL_ERROR.
      Parameters:
      e - The exception thrown by the callback handler
    • callOnWritable

      public void callOnWritable()
      Calls the onWritable callback.
    • callOnError

      public void callOnError(Exception err)
      Calls the onError callback.
      Parameters:
      err - The object to pass to the callback
    • getRequest

      public HTTPRequest getRequest()
      Description copied from interface: HTTPMessageStream
      Returns the request of this HTTPMessageStream.
      Specified by:
      getRequest in interface HTTPMessageStream
      Returns:
      The request
    • onWritable

      public void onWritable(Runnable onWritable)
      Description copied from interface: HTTPMessageStream
      Sets a callback that is called when this HTTPMessageStream has cleared its write buffer after a sendData call returned false.
      Specified by:
      onWritable in interface HTTPMessageStream
      Parameters:
      onWritable - The callback
    • onError

      public void onError(Consumer<Exception> onError)
      Description copied from interface: HTTPMessageStream
      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.
      Specified by:
      onError in interface HTTPMessageStream
      Parameters:
      onError - The callback
    • isClosed

      public boolean isClosed()
      Description copied from interface: HTTPMessageStream
      Returns true if this HTTPMessageStream has closed, either forcibly (via HTTPMessageStream.close()) or because the request transaction has completed.
      Specified by:
      isClosed in interface HTTPMessageStream
      Returns:
      true if closed