Interface BodyDecoder<T>
- Type Parameters:
T- the subscriber's body type
- All Superinterfaces:
Flow.Subscriber<List<ByteBuffer>>, HttpResponse.BodySubscriber<T>
- All Known Implementing Classes:
AsyncBodyDecoder
A
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. 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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA factory ofBodyDecoderinstances for some defined encoding. -
Method Summary
Modifier and TypeMethodDescriptionReturns this decoder's downstream.encoding()Returns the encoding used by this decoder.executor()Returns this decoder's executor if one is specified.default CompletionStage<T> getBody()Returns the body'sCompletionStage.Methods inherited from interface Flow.Subscriber
onComplete, onError, onNext, onSubscribe
-
Method Details
-
encoding
String encoding()Returns the encoding used by this decoder. This corresponds to the value of theContent-Typeheader. -
executor
-
downstream
HttpResponse.BodySubscriber<T> downstream()Returns this decoder's downstream. -
getBody
Returns the body'sCompletionStage.- Specified by:
getBodyin interfaceHttpResponse.BodySubscriber<T>
-