Interface HttpChannel.Listener

All Superinterfaces:
EventListener
All Known Implementing Classes:
HttpChannel.TransientListeners, HttpChannelListeners
Enclosing class:
HttpChannel

public static interface HttpChannel.Listener extends EventListener

Listener for HttpChannel events.

HttpChannel will emit events for the various phases it goes through while processing an HTTP request and response.

Implementations of this interface may listen to those events to track timing and/or other values such as request URI, etc.

The events parameters, especially the Request object, may be in a transient state depending on the event, and not all properties/features of the parameters may be available inside a listener method.

It is recommended that the event parameters are not acted upon in the listener methods, or undefined behavior may result. For example, it would be a bad idea to try to read some content from the ServletInputStream in listener methods. On the other hand, it is legit to store request attributes in one listener method that may be possibly retrieved in another listener method in a later event.

Listener methods are invoked synchronously from the thread that is performing the request processing, and they should not call blocking code (otherwise the request processing will be blocked as well).

Listener instances that are set as a bean on the Connector are efficiently added to HttpChannel. If additional listeners are added using the deprecated HttpChannel.addListener(Listener)

method, then an instance of HttpChannel.TransientListeners must be added to the connector in order for them to be invoked.
  • Method Details

    • onRequestBegin

      default void onRequestBegin(Request request)
      Invoked just after the HTTP request line and headers have been parsed.
      Parameters:
      request - the request object
    • onBeforeDispatch

      default void onBeforeDispatch(Request request)
      Invoked just before calling the application.
      Parameters:
      request - the request object
    • onDispatchFailure

      default void onDispatchFailure(Request request, Throwable failure)
      Invoked when the application threw an exception.
      Parameters:
      request - the request object
      failure - the exception thrown by the application
    • onAfterDispatch

      default void onAfterDispatch(Request request)
      Invoked just after the application returns from the first invocation.
      Parameters:
      request - the request object
    • onRequestContent

      default void onRequestContent(Request request, ByteBuffer content)
      Invoked every time a request content chunk has been parsed, just before making it available to the application.
      Parameters:
      request - the request object
      content - a slice of the request content chunk
    • onRequestContentEnd

      default void onRequestContentEnd(Request request)
      Invoked when the end of the request content is detected.
      Parameters:
      request - the request object
    • onRequestTrailers

      default void onRequestTrailers(Request request)
      Invoked when the request trailers have been parsed.
      Parameters:
      request - the request object
    • onRequestEnd

      default void onRequestEnd(Request request)
      Invoked when the request has been fully parsed.
      Parameters:
      request - the request object
    • onRequestFailure

      default void onRequestFailure(Request request, Throwable failure)
      Invoked when the request processing failed.
      Parameters:
      request - the request object
      failure - the request failure
    • onResponseBegin

      default void onResponseBegin(Request request)
      Invoked just before the response line is written to the network.
      Parameters:
      request - the request object
    • onResponseCommit

      default void onResponseCommit(Request request)
      Invoked just after the response is committed (that is, the response line, headers and possibly some content have been written to the network).
      Parameters:
      request - the request object
    • onResponseContent

      default void onResponseContent(Request request, ByteBuffer content)
      Invoked after a response content chunk has been written to the network.
      Parameters:
      request - the request object
      content - a slice of the response content chunk
    • onResponseEnd

      default void onResponseEnd(Request request)
      Invoked when the response has been fully written.
      Parameters:
      request - the request object
    • onResponseFailure

      default void onResponseFailure(Request request, Throwable failure)
      Invoked when the response processing failed.
      Parameters:
      request - the request object
      failure - the response failure
    • onComplete

      default void onComplete(Request request)
      Invoked when the request and response processing are complete.
      Parameters:
      request - the request object