Class ReactiveResponseConsumer
java.lang.Object
org.apache.hc.core5.reactive.ReactiveResponseConsumer
- All Implemented Interfaces:
org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<Void>, org.apache.hc.core5.http.nio.ResourceHolder
@Contract(threading=SAFE)
public final class ReactiveResponseConsumer
extends Object
implements org.apache.hc.core5.http.nio.AsyncResponseConsumer<Void>
An
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.- Since:
- 5.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aReactiveResponseConsumer.ReactiveResponseConsumer(org.apache.hc.core5.concurrent.FutureCallback<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse, org.reactivestreams.Publisher<ByteBuffer>>> responseCallback) Creates aReactiveResponseConsumerthat will call back the suppliedFutureCallbackwith a streamable response. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume(ByteBuffer src) voidconsumeResponse(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.EntityDetails entityDetails, org.apache.hc.core5.http.protocol.HttpContext httpContext, org.apache.hc.core5.concurrent.FutureCallback<Void> resultCallback) voidorg.apache.hc.core5.http.EntityDetailsReturns the response entity details.org.apache.hc.core5.http.HttpResponseReturns the intermediate (1xx) HTTP response if one was received.Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse, org.reactivestreams.Publisher<ByteBuffer>>> List<org.apache.hc.core5.http.Header> Returns the trailers received at the end of the response.voidinformationResponse(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext httpContext) voidvoidvoidupdateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel)
-
Constructor Details
-
ReactiveResponseConsumer
public ReactiveResponseConsumer()Creates aReactiveResponseConsumer. -
ReactiveResponseConsumer
public ReactiveResponseConsumer(org.apache.hc.core5.concurrent.FutureCallback<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse, org.reactivestreams.Publisher<ByteBuffer>>> responseCallback) Creates aReactiveResponseConsumerthat will call back the suppliedFutureCallbackwith a streamable response.- Parameters:
responseCallback- the callback to invoke when the response is available for consumption.
-
-
Method Details
-
getResponseFuture
public Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse, org.reactivestreams.Publisher<ByteBuffer>>> getResponseFuture() -
getInformationResponse
public org.apache.hc.core5.http.HttpResponse getInformationResponse()Returns the intermediate (1xx) HTTP response if one was received.- Returns:
- the information response, or
nullif none.
-
getEntityDetails
public org.apache.hc.core5.http.EntityDetails getEntityDetails()Returns the response entity details.- Returns:
- the entity details, or
nullif none.
-
getTrailers
Returns the trailers received at the end of the response.- Returns:
- a non-null list of zero or more trailers.
-
consumeResponse
public void consumeResponse(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.EntityDetails entityDetails, org.apache.hc.core5.http.protocol.HttpContext httpContext, org.apache.hc.core5.concurrent.FutureCallback<Void> resultCallback) - Specified by:
consumeResponsein interfaceorg.apache.hc.core5.http.nio.AsyncResponseConsumer<Void>
-
informationResponse
public void informationResponse(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext httpContext) - Specified by:
informationResponsein interfaceorg.apache.hc.core5.http.nio.AsyncResponseConsumer<Void>
-
failed
-
updateCapacity
public void updateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel) throws IOException - Specified by:
updateCapacityin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOException
-
consume
- Specified by:
consumein interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
IOException
-
streamEnd
- Specified by:
streamEndin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer
-
releaseResources
public void releaseResources()- Specified by:
releaseResourcesin interfaceorg.apache.hc.core5.http.nio.ResourceHolder
-