Package software.amazon.awssdk.crt.http
Interface HttpStreamResponseHandler
-
public interface HttpStreamResponseHandler
Interface that Native code knows how to call when handling Http Responses 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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 Detail
-
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 objectresponseStatusCode
- The HTTP Response Status CodeblockType
- The HTTP header block typenextHeaders
- 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 objectblockType
- The type of the header block, corresponds toHttpHeaderBlock
-
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. Users must read all data from bodyBytesIn before returning. If "bodyBytesIn.remaining() > 0" after this method returns, then Native will assume there was a processing failure and abort the connection. Do NOT keep a reference to this ByteBuffer past the lifetime of this function call. The CommonRuntime reserves the right to use DirectByteBuffers pointing to memory that only lives as long as the function call. Sliding Window: The Native HttpClientConnection EventLoop will keep sending data until the end of the sliding Window is reached. The user application is responsible for setting the initial Window size appropriately when creating the HttpClientConnection, and for incrementing the sliding window appropriately throughout the lifetime of the HttpStream. For more info, see: - https://en.wikipedia.org/wiki/Sliding_window_protocol- Parameters:
stream
- The HTTP Stream the body was delivered tobodyBytesIn
- The HTTP Body Bytes received in the last IO Event.- Returns:
- The number of bytes to move the sliding window by. Repeatedly returning zero will eventually cause the sliding window to fill up and data to stop flowing until the user slides the window back open.
-
onResponseComplete
void onResponseComplete(HttpStream stream, int errorCode)
Called from Native when the Response has completed.- Parameters:
stream
- completed streamerrorCode
- resultant errorCode for the response
-
-