Interface HttpLifecycleObserver.HttpResponseObserver

All Known Subinterfaces:
GrpcLifecycleObserver.GrpcResponseObserver
Enclosing interface:
HttpLifecycleObserver

public static interface HttpLifecycleObserver.HttpResponseObserver
An observer interface that provides visibility into events associated with a single HTTP response.

The response is considered complete when one of the terminal events is invoked. It is guaranteed that only one terminal event will be invoked per response.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Callback when the response is cancelled.
    default void
    Callback when the response completes successfully.
    default void
    Callback when a response payload body data chunk was observed.
    default void
    Callback when the subscriber requests n items of the response payload body.
    default void
    Callback when the response fails with an error.
    default void
    Callback when response trailers were observed.
  • Method Details

    • onResponseDataRequested

      default void onResponseDataRequested(long n)
      Callback when the subscriber requests n items of the response payload body.

      May be invoked multiple times and concurrently with other callbacks on this observer. Therefore, it should have its own isolated state or should be synchronized if the state is shared with other callbacks. It can help to track when items are requested and when they are delivered.

      Parameters:
      n - number of requested items
    • onResponseData

      default void onResponseData(Buffer data)
      Callback when a response payload body data chunk was observed.

      May be invoked multiple times if the payload body is split into multiple chunks. All invocations are sequential between this and other callbacks except onResponseDataRequested(long).

      Parameters:
      data - the response payload body data chunk
    • onResponseTrailers

      default void onResponseTrailers(HttpHeaders trailers)
      Callback when response trailers were observed.

      May be invoked zero times (if no trailers are present in the response) or once after all response data chunks are observed.

      Parameters:
      trailers - trailers of the response
    • onResponseComplete

      default void onResponseComplete()
      Callback when the response completes successfully.

      This is one of the possible terminal events.

    • onResponseError

      default void onResponseError(Throwable cause)
      Callback when the response fails with an error.

      This is one of the possible terminal events.

      Parameters:
      cause - Throwable that terminated this response
    • onResponseCancel

      default void onResponseCancel()
      Callback when the response is cancelled.

      This is one of the possible terminal events. Cancellation is the best effort, more events may be signaled after cancel.