Interface HttpStreamResponseHandler


public interface HttpStreamResponseHandler
Interface that Native code knows how to call when handling Http Responses for HTTP/1.1 only. You can use HttpStreamBaseResponseHandler instead to adapt both HTTP/1.1 and HTTP/2 Maps 1-1 to the Native Http API here: https://github.com/awslabs/aws-c-http/blob/master/include/aws/http/request_response.h
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Called right before stream is complete, whether successful or unsuccessful.
    default int
    onResponseBody(HttpStream stream, byte[] bodyBytesIn)
    Called when new Response Body bytes have been received.
    void
    onResponseComplete(HttpStream stream, int errorCode)
    Called from Native when the Response has completed.
    void
    onResponseHeaders(HttpStream stream, int responseStatusCode, int blockType, HttpHeader[] nextHeaders)
    Called from Native when new Http Headers have been received.
    default void
    onResponseHeadersDone(HttpStream stream, int blockType)
    Called from Native once all HTTP Headers are processed.
  • Method Details

    • onResponseHeaders

      void onResponseHeaders(HttpStream stream, int responseStatusCode, int blockType, HttpHeader[] nextHeaders)
      Called from Native when new Http Headers have been received. Note that this function may be called multiple times as HTTP headers are received.
      Parameters:
      stream - The HttpStream object
      responseStatusCode - The HTTP Response Status Code
      blockType - The HTTP header block type
      nextHeaders - The headers received in the latest IO event.
    • onResponseHeadersDone

      default void onResponseHeadersDone(HttpStream stream, int blockType)
      Called from Native once all HTTP Headers are processed. Will not be called if there are no Http Headers in the response. Guaranteed to be called exactly once if there is at least 1 Header.
      Parameters:
      stream - The HttpStream object
      blockType - The type of the header block, corresponds to HttpHeaderBlock
    • onResponseBody

      default int onResponseBody(HttpStream stream, byte[] bodyBytesIn)
      Called when new Response Body bytes have been received. Note that this function may be called multiple times over the lifetime of an HttpClientConnection as bytes are received.

      Note that if HttpClientConnectionManagerOptions.withManualWindowManagement(boolean) was set true, you must manage the flow-control window. The flow-control window shrinks as you receive body data via this callback. Whenever the flow-control window reaches zero, data will stop downloading. To keep data flowing, you must increment the window by returning a number from this method, or by calling HttpStreamBase.incrementWindow(int).

      Parameters:
      stream - The HTTP Stream the body was delivered to
      bodyBytesIn - The HTTP Body Bytes received in the last IO Event.
      Returns:
      The number of bytes to increment the window by (calling HttpStreamBase.incrementWindow(int) has the same effect). This value is ignored if "manual window management" is disabled.
      See Also:
    • onMetrics

      default void onMetrics(HttpStream stream, HttpStreamMetrics metrics)
      Called right before stream is complete, whether successful or unsuccessful.
      Parameters:
      stream - The HTTP stream to which the metrics apply
      metrics - The [HttpStreamMetrics] containing metrics for the given stream
    • onResponseComplete

      void onResponseComplete(HttpStream stream, int errorCode)
      Called from Native when the Response has completed.
      Parameters:
      stream - completed stream
      errorCode - resultant errorCode for the response