@Contract(threading=SAFE) public final class ReactiveResponseConsumer extends Object implements AsyncResponseConsumer<Void>
AsyncResponseConsumer
that publishes the response body through
a Publisher
, as defined by the Reactive Streams specification. The
response is represented as a Message
consisting of a HttpResponse
representing the headers and a Publisher
representing
the response body as an asynchronous stream of ByteBuffer
instances.Constructor and Description |
---|
ReactiveResponseConsumer()
Creates a
ReactiveResponseConsumer . |
ReactiveResponseConsumer(FutureCallback<Message<HttpResponse,org.reactivestreams.Publisher<ByteBuffer>>> responseCallback)
Creates a
ReactiveResponseConsumer that will call back the supplied FutureCallback with a
streamable response. |
Modifier and Type | Method and Description |
---|---|
void |
consume(ByteBuffer src)
Triggered to pass incoming data to the data consumer.
|
void |
consumeResponse(HttpResponse response,
EntityDetails entityDetails,
HttpContext httpContext,
FutureCallback<Void> resultCallback)
Triggered to signal receipt of a response message head.
|
void |
failed(Exception cause)
Triggered to signal a failure in data processing.
|
EntityDetails |
getEntityDetails()
Returns the response entity details.
|
HttpResponse |
getInformationResponse()
Returns the intermediate (1xx) HTTP response if one was received.
|
Future<Message<HttpResponse,org.reactivestreams.Publisher<ByteBuffer>>> |
getResponseFuture() |
List<Header> |
getTrailers()
Returns the trailers received at the end of the response.
|
void |
informationResponse(HttpResponse response,
HttpContext httpContext)
Triggered to signal receipt of an intermediate (1xx) HTTP response.
|
void |
releaseResources() |
void |
streamEnd(List<? extends Header> trailers)
Triggered to signal termination of the data stream.
|
void |
updateCapacity(CapacityChannel capacityChannel)
Triggered to signal ability of the underlying data stream to receive
data capacity update.
|
public ReactiveResponseConsumer()
ReactiveResponseConsumer
.public ReactiveResponseConsumer(FutureCallback<Message<HttpResponse,org.reactivestreams.Publisher<ByteBuffer>>> responseCallback)
ReactiveResponseConsumer
that will call back the supplied FutureCallback
with a
streamable response.responseCallback
- the callback to invoke when the response is available for consumption.public Future<Message<HttpResponse,org.reactivestreams.Publisher<ByteBuffer>>> getResponseFuture()
public HttpResponse getInformationResponse()
null
if none.public EntityDetails getEntityDetails()
null
if none.public List<Header> getTrailers()
public void consumeResponse(HttpResponse response, EntityDetails entityDetails, HttpContext httpContext, FutureCallback<Void> resultCallback)
AsyncResponseConsumer
consumeResponse
in interface AsyncResponseConsumer<Void>
response
- the response message head.entityDetails
- the response entity details or null
if the response
does not enclose an entity.httpContext
- the actual execution context.resultCallback
- the result callback called when response processing
has been completed successfully or unsuccessfully.public void informationResponse(HttpResponse response, HttpContext httpContext)
AsyncResponseConsumer
informationResponse
in interface AsyncResponseConsumer<Void>
response
- the intermediate (1xx) HTTP response.httpContext
- the actual execution context.public void failed(Exception cause)
AsyncResponseConsumer
failed
in interface AsyncResponseConsumer<Void>
cause
- the cause of the failure.public void updateCapacity(CapacityChannel capacityChannel) throws IOException
AsyncDataConsumer
updateCapacity
in interface AsyncDataConsumer
capacityChannel
- the channel for capacity updates.IOException
public void consume(ByteBuffer src) throws IOException
AsyncDataConsumer
consume
in interface AsyncDataConsumer
src
- data source.IOException
public void streamEnd(List<? extends Header> trailers)
AsyncDataConsumer
streamEnd
in interface AsyncDataConsumer
trailers
- data stream trailers.public void releaseResources()
releaseResources
in interface ResourceHolder
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.