Top Description Fields Constructors Methods
org.apache.hc.core5.reactive

public final Class ReactiveResponseConsumer

extends Object
implements AsyncResponseConsumer<Void>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncResponseConsumer, org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.ResourceHolder
Annotations
@Contract
threading:SAFE
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.ArrayList, .Collections, .List, java.util.concurrent.Future, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.concurrent.BasicFuture, .FutureCallback, org.apache.hc.core5.http.EntityDetails, .Header, .HttpResponse, .Message, org.apache.hc.core5.http.nio.AsyncResponseConsumer, .CapacityChannel, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.util.Args, org.reactivestreams.Publisher

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

Field Summary

Modifier and TypeField and Description
private volatile EntityDetails
private volatile HttpResponse
private final ReactiveDataConsumer
private volatile BasicFuture<Void>
private final BasicFuture<Message<HttpResponse, Publisher<ByteBuffer>>>
private final List<Header>

Constructor Summary

AccessConstructor and Description
public
ReactiveResponseConsumer()

Creates a ReactiveResponseConsumer.

public
ReactiveResponseConsumer(final FutureCallback<Message<HttpResponse, Publisher<ByteBuffer>>>
the callback to invoke when the response is available for consumption.
responseCallback
)

Creates a ReactiveResponseConsumer that will call back the supplied FutureCallback with a streamable response.

Method Summary

Modifier and TypeMethod and Description
public void
consume(final ByteBuffer
data source.
src
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Triggered to pass incoming data to the data consumer.
public void
consumeResponse(final HttpResponse
the response message head.
response
,
final EntityDetails
the response entity details or null if the response does not enclose an entity.
entityDetails
,
final HttpContext
the actual execution context.
httpContext
,
final FutureCallback<Void>
the result callback called when response processing has been completed successfully or unsuccessfully.
resultCallback
)

Implements org.apache.hc.core5.http.nio.AsyncResponseConsumer.consumeResponse.

Triggered to signal receipt of a response message head.
public void
failed(final Exception
the cause of the failure.
cause
)

Implements org.apache.hc.core5.http.nio.AsyncResponseConsumer.failed.

Triggered to signal a failure in data processing.
public EntityDetails

Returns:

the entity details, or null if none.
getEntityDetails
()

Returns the response entity details.

public HttpResponse

Returns:

the information response, or null if none.
getInformationResponse
()

Returns the intermediate (1xx) HTTP response if one was received.

public Future<Message<HttpResponse, Publisher<ByteBuffer>>>
public List<Header>

Returns:

a non-null list of zero or more trailers.
getTrailers
()

Returns the trailers received at the end of the response.

public void
informationResponse(final HttpResponse
the intermediate (1xx) HTTP response.
response
,
final HttpContext
the actual execution context.
httpContext
)

Implements org.apache.hc.core5.http.nio.AsyncResponseConsumer.informationResponse.

Triggered to signal receipt of an intermediate (1xx) HTTP response.
public void
public void
streamEnd(final List<? extends Header>
data stream trailers.
trailers
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Triggered to signal termination of the data stream.
public void
updateCapacity(final CapacityChannel
the channel for capacity updates.
capacityChannel
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Triggered to signal ability of the underlying data stream to receive data capacity update.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entityDetailsback to summary
private volatile EntityDetails entityDetails
informationResponseback to summary
private volatile HttpResponse informationResponse
reactiveDataConsumerback to summary
private final ReactiveDataConsumer reactiveDataConsumer
responseCompletionback to summary
private volatile BasicFuture<Void> responseCompletion
responseFutureback to summary
private final BasicFuture<Message<HttpResponse, Publisher<ByteBuffer>>> responseFuture
trailersback to summary
private final List<Header> trailers

Constructor Detail

ReactiveResponseConsumerback to summary
public ReactiveResponseConsumer()

Creates a ReactiveResponseConsumer.

ReactiveResponseConsumerback to summary
public ReactiveResponseConsumer(final FutureCallback<Message<HttpResponse, Publisher<ByteBuffer>>> responseCallback)

Creates a ReactiveResponseConsumer that will call back the supplied FutureCallback with a streamable response.

Parameters
responseCallback:FutureCallback<Message<HttpResponse, Publisher<ByteBuffer>>>

the callback to invoke when the response is available for consumption.

Method Detail

consumeback to summary
public void consume(final ByteBuffer src) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Triggered to pass incoming data to the data consumer. The consumer must consume the entire content of the data buffer. The consumer must stop incrementing its capacity on the capacity channel if it is unable to accept more data. Once the data consumer has handled accumulated data or allocated more intermediate storage it can update its capacity information on the capacity channel.

Parameters
src:ByteBuffer

data source.

Annotations
@Override
consumeResponseback to summary
public void consumeResponse(final HttpResponse response, final EntityDetails entityDetails, final HttpContext httpContext, final FutureCallback<Void> resultCallback)

Implements org.apache.hc.core5.http.nio.AsyncResponseConsumer.consumeResponse.

Doc from org.apache.hc.core5.http.nio.AsyncResponseConsumer.consumeResponse.

Triggered to signal receipt of a response message head.

Parameters
response:HttpResponse

the response message head.

entityDetails:EntityDetails

the response entity details or null if the response does not enclose an entity.

httpContext:HttpContext

the actual execution context.

resultCallback:FutureCallback<Void>

the result callback called when response processing has been completed successfully or unsuccessfully.

Annotations
@Override
failedback to summary
public void failed(final Exception cause)

Implements org.apache.hc.core5.http.nio.AsyncResponseConsumer.failed.

Doc from org.apache.hc.core5.http.nio.AsyncResponseConsumer.failed.

Triggered to signal a failure in data processing.

Parameters
cause:Exception

the cause of the failure.

Annotations
@Override
getEntityDetailsback to summary
public EntityDetails getEntityDetails()

Returns the response entity details.

Returns:EntityDetails

the entity details, or null if none.

getInformationResponseback to summary
public HttpResponse getInformationResponse()

Returns the intermediate (1xx) HTTP response if one was received.

Returns:HttpResponse

the information response, or null if none.

getResponseFutureback to summary
public Future<Message<HttpResponse, Publisher<ByteBuffer>>> getResponseFuture()
getTrailersback to summary
public List<Header> getTrailers()

Returns the trailers received at the end of the response.

Returns:List<Header>

a non-null list of zero or more trailers.

informationResponseback to summary
public void informationResponse(final HttpResponse response, final HttpContext httpContext)

Implements org.apache.hc.core5.http.nio.AsyncResponseConsumer.informationResponse.

Doc from org.apache.hc.core5.http.nio.AsyncResponseConsumer.informationResponse.

Triggered to signal receipt of an intermediate (1xx) HTTP response.

Parameters
response:HttpResponse

the intermediate (1xx) HTTP response.

httpContext:HttpContext

the actual execution context.

Annotations
@Override
releaseResourcesback to summary
public void releaseResources()

Implements org.apache.hc.core5.http.nio.ResourceHolder.releaseResources.

Annotations
@Override
streamEndback to summary
public void streamEnd(final List<? extends Header> trailers)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Triggered to signal termination of the data stream.

Parameters
trailers:List<? extends Header>

data stream trailers.

Annotations
@Override
updateCapacityback to summary
public void updateCapacity(final CapacityChannel capacityChannel) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Triggered to signal ability of the underlying data stream to receive data capacity update. The data consumer can choose to write data immediately inside the call or asynchronously at some later point.

Parameters
capacityChannel:CapacityChannel

the channel for capacity updates.

Annotations
@Override