ResponseT
- Response POJO type.ReturnT
- Transformation result type. Returned by complete()
public class UnmarshallingAsyncResponseHandler<ResponseT,ReturnT> extends Object implements SdkHttpResponseHandler<ReturnT>
AsyncResponseTransformer
to a SdkHttpResponseHandler
by first performing unmarshalling
on the initial response (headers/status code).Constructor and Description |
---|
UnmarshallingAsyncResponseHandler(AsyncResponseTransformer<ResponseT,ReturnT> asyncResponseTransformer,
FunctionalUtils.UnsafeFunction<SdkHttpResponse,ResponseT> unmarshaller) |
Modifier and Type | Method and Description |
---|---|
ReturnT |
complete()
Called when all parts of the response have been received.
|
void |
exceptionOccurred(Throwable throwable)
Called when an exception occurs during the request/response.
|
void |
headersReceived(SdkHttpResponse response)
Called when the initial response with headers is received.
|
void |
onStream(org.reactivestreams.Publisher<ByteBuffer> publisher)
Called when the HTTP client is ready to start sending data to the response handler.
|
public UnmarshallingAsyncResponseHandler(AsyncResponseTransformer<ResponseT,ReturnT> asyncResponseTransformer, FunctionalUtils.UnsafeFunction<SdkHttpResponse,ResponseT> unmarshaller)
asyncResponseTransformer
- Response handler being adapted.unmarshaller
- Unmarshaller that takes an SdkHttpResponse
and returns the unmarshalled POJO.public void headersReceived(SdkHttpResponse response)
SdkHttpResponseHandler
headersReceived
in interface SdkHttpResponseHandler<ReturnT>
response
- the SdkHttpResponse
public void onStream(org.reactivestreams.Publisher<ByteBuffer> publisher)
SdkHttpResponseHandler
Publisher
and request data via a Subscription
as
they can handle it.
If at any time the subscriber wishes to stop receiving data, it may call Subscription.cancel()
. This
will be treated as a failure of the response and the SdkHttpResponseHandler.exceptionOccurred(Throwable)
callback will be invoked.
onStream
in interface SdkHttpResponseHandler<ReturnT>
public void exceptionOccurred(Throwable throwable)
SdkHttpResponseHandler
SdkHttpResponseHandler
after this point.exceptionOccurred
in interface SdkHttpResponseHandler<ReturnT>
throwable
- the exception that occurred.public ReturnT complete()
SdkHttpResponseHandler
SdkHttpResponseHandler
after this point.complete
in interface SdkHttpResponseHandler<ReturnT>
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.