Package org.apache.hc.core5.reactive
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<java.lang.Void>,org.apache.hc.core5.http.nio.ResourceHolder
@Contract(threading=SAFE) public final class ReactiveResponseConsumer extends java.lang.Object implements org.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.Void>AnAsyncResponseConsumerthat publishes the response body through aPublisher, as defined by the Reactive Streams specification. The response is represented as aMessageconsisting of aHttpResponserepresenting the headers and aPublisherrepresenting the response body as an asynchronous stream ofByteBufferinstances.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description ReactiveResponseConsumer()Creates aReactiveResponseConsumer.ReactiveResponseConsumer(org.apache.hc.core5.concurrent.FutureCallback<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse,org.reactivestreams.Publisher<java.nio.ByteBuffer>>> responseCallback)Creates aReactiveResponseConsumerthat will call back the suppliedFutureCallbackwith a streamable response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconsume(java.nio.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<java.lang.Void> resultCallback)voidfailed(java.lang.Exception cause)org.apache.hc.core5.http.EntityDetailsgetEntityDetails()Returns the response entity details.org.apache.hc.core5.http.HttpResponsegetInformationResponse()Returns the intermediate (1xx) HTTP response if one was received.java.util.concurrent.Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse,org.reactivestreams.Publisher<java.nio.ByteBuffer>>>getResponseFuture()java.util.List<org.apache.hc.core5.http.Header>getTrailers()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)voidreleaseResources()voidstreamEnd(java.util.List<? extends org.apache.hc.core5.http.Header> trailers)voidupdateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel)
-
-
-
Constructor Detail
-
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<java.nio.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 Detail
-
getResponseFuture
public java.util.concurrent.Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse,org.reactivestreams.Publisher<java.nio.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
public java.util.List<org.apache.hc.core5.http.Header> 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<java.lang.Void> resultCallback)- Specified by:
consumeResponsein interfaceorg.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.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<java.lang.Void>
-
failed
public void failed(java.lang.Exception cause)
- Specified by:
failedin interfaceorg.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.Void>
-
updateCapacity
public void updateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel) throws java.io.IOException- Specified by:
updateCapacityin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
java.io.IOException
-
consume
public void consume(java.nio.ByteBuffer src) throws java.io.IOException- Specified by:
consumein interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer- Throws:
java.io.IOException
-
streamEnd
public void streamEnd(java.util.List<? extends org.apache.hc.core5.http.Header> trailers)
- Specified by:
streamEndin interfaceorg.apache.hc.core5.http.nio.AsyncDataConsumer
-
releaseResources
public void releaseResources()
- Specified by:
releaseResourcesin interfaceorg.apache.hc.core5.http.nio.ResourceHolder
-
-