- Type Parameters:
T
- the subscriber's body type
- All Superinterfaces:
Flow.Subscriber<List<ByteBuffer>>
,HttpResponse.BodySubscriber<T>
- All Known Implementing Classes:
AsyncBodyDecoder
HttpResponse.BodySubscriber
that decodes the response body for consumption by a downstream
subscriber. Despite not implementing the interface, a BodyDecoder
has the same semantics
of a Processor
<List<ByteBuffer>,
List<ByteBuffer>>
. It takes lists of ByteBuffers
from the HTTP client, then publishes
their decompressed form to the downstream subscriber
, which itself converts
the former to the desired high-level type.
The guarantees given by the HTTP client are also given by the decoder; the downstream receives
a strictly ordered representation of the decoded response body in the form of immutable lists of
read-only ByteBuffers
, which up on being passed, are no longer referenced by the decoder.
Optionally, a BodyDecoder
can have an Executor
. If present, the executor is
used to deliver downstream signals (that is, downstream's onXXXX methods are dispatched to the
executor). This can lead to overlapped processing between the two subscribers. If an executor is
not present, the decoder processes and supplies downstream items in the same thread, which is
normally the upstream thread supplying the compressed ByteBuffers
.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A factory ofBodyDecoders
for some defined encoding. -
Method Summary
Modifier and TypeMethodDescriptionReturns this decoder's downstream.encoding()
Returns the encoding used by this decoder.executor()
Returns anOptional
containing this decoder's executor.default CompletionStage
<T> getBody()
Returns the body'sCompletionStage
.Methods inherited from interface java.util.concurrent.Flow.Subscriber
onComplete, onError, onNext, onSubscribe
-
Method Details
-
encoding
String encoding()Returns the encoding used by this decoder. Normally, this corresponds to the value of theContent-Type
header. -
executor
Returns anOptional
containing this decoder's executor. An empty optional is returned if the decoder is in "synchronous" mode. -
downstream
HttpResponse.BodySubscriber<T> downstream()Returns this decoder's downstream. -
getBody
Returns the body'sCompletionStage
.Since this subscriber only acts as a processing stage, the default implementation simply returns the body completion stage of the downstream.
- Specified by:
getBody
in interfaceHttpResponse.BodySubscriber<T>
-