Class ClassicToAsyncResponseConsumer
java.lang.Object
org.apache.hc.core5.http.nio.support.classic.ClassicToAsyncResponseConsumer
- All Implemented Interfaces:
AsyncDataConsumer, AsyncResponseConsumer<Void>, ResourceHolder
@Experimental
public class ClassicToAsyncResponseConsumer
extends Object
implements AsyncResponseConsumer<Void>
- Since:
- 5.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicReference<SharedInputBuffer> private final AtomicReference<FutureCallback<Void>> private final CountDownLatchprivate final AtomicReference<Exception> private final intprivate final AtomicReference<ClassicToAsyncResponseConsumer.ResponseData> private final Timeout -
Constructor Summary
ConstructorsConstructorDescriptionClassicToAsyncResponseConsumer(int initialBufferSize, Timeout timeout) ClassicToAsyncResponseConsumer(Timeout timeout) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidconsume(ByteBuffer src) Triggered to pass incoming data to the data consumer.voidconsumeResponse(HttpResponse asyncResponse, EntityDetails entityDetails, HttpContext context, FutureCallback<Void> resultCallback) Triggered to signal receipt of a response message head.final voidTriggered to signal a failure in data processing.(package private) voidvoidinformationResponse(HttpResponse response, HttpContext context) Triggered to signal receipt of an intermediate (1xx) HTTP response.(package private) voidvoidfinal voidTriggered to signal termination of the data stream.final voidupdateCapacity(CapacityChannel capacityChannel) Triggered to signal ability of the underlying data stream to receive data capacity update.
-
Field Details
-
initialBufferSize
private final int initialBufferSize -
timeout
-
countDownLatch
-
responseRef
-
callbackRef
-
bufferRef
-
exceptionRef
-
-
Constructor Details
-
ClassicToAsyncResponseConsumer
-
ClassicToAsyncResponseConsumer
-
-
Method Details
-
propagateException
- Throws:
IOException
-
fireComplete
- Throws:
IOException
-
blockWaiting
- Throws:
IOExceptionInterruptedException
-
consumeResponse
public void consumeResponse(HttpResponse asyncResponse, EntityDetails entityDetails, HttpContext context, FutureCallback<Void> resultCallback) throws HttpException, IOException Description copied from interface:AsyncResponseConsumerTriggered to signal receipt of a response message head.- Specified by:
consumeResponsein interfaceAsyncResponseConsumer<Void>- Parameters:
asyncResponse- the response message head.entityDetails- the response entity details ornullif the response does not enclose an entity.context- the actual execution context.resultCallback- the result callback called when response processing has been completed successfully or unsuccessfully.- Throws:
HttpException- in case of an HTTP protocol violation.IOException- in case of an I/O error.
-
informationResponse
public void informationResponse(HttpResponse response, HttpContext context) throws HttpException, IOException Description copied from interface:AsyncResponseConsumerTriggered to signal receipt of an intermediate (1xx) HTTP response.- Specified by:
informationResponsein interfaceAsyncResponseConsumer<Void>- Parameters:
response- the intermediate (1xx) HTTP response.context- the actual execution context.- Throws:
HttpException- in case of an HTTP protocol violation.IOException- in case of an I/O error.
-
updateCapacity
Description copied from interface:AsyncDataConsumerTriggered 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.- Specified by:
updateCapacityin interfaceAsyncDataConsumer- Parameters:
capacityChannel- the channel for capacity updates.- Throws:
IOException- in case of an I/O error.
-
consume
Description copied from interface:AsyncDataConsumerTriggered 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.- Specified by:
consumein interfaceAsyncDataConsumer- Parameters:
src- data source.- Throws:
IOException- in case of an I/O error.
-
streamEnd
Description copied from interface:AsyncDataConsumerTriggered to signal termination of the data stream.- Specified by:
streamEndin interfaceAsyncDataConsumer- Parameters:
trailers- data stream trailers.- Throws:
HttpException- in case of an HTTP protocol violation.IOException- in case of an I/O error.
-
failed
Description copied from interface:AsyncResponseConsumerTriggered to signal a failure in data processing.- Specified by:
failedin interfaceAsyncResponseConsumer<Void>- Parameters:
cause- the cause of the failure.
-
releaseResources
public void releaseResources()- Specified by:
releaseResourcesin interfaceResourceHolder
-