-
- Type Parameters:
T- the subscriber's body type
- All Superinterfaces:
java.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>,java.net.http.HttpResponse.BodySubscriber<T>
- All Known Implementing Classes:
AsyncBodyDecoder
public interface BodyDecoder<T> extends java.net.http.HttpResponse.BodySubscriber<T>AHttpResponse.BodySubscriberthat decodes the response body for consumption by a downstream subscriber. Despite not implementing the interface, aBodyDecoderhas the same semantics of aProcessor<List<ByteBuffer>, List<ByteBuffer>>. It takes lists ofByteBuffersfrom the HTTP client, then publishes their decompressed form to thedownstream 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
BodyDecodercan have anExecutor. 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 compressedByteBuffers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceBodyDecoder.FactoryA factory ofBodyDecoderinstances for some defined encoding.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.net.http.HttpResponse.BodySubscriber<T>downstream()Returns this decoder's downstream.java.lang.Stringencoding()Returns the encoding used by this decoder.java.util.Optional<java.util.concurrent.Executor>executor()Returns this decoder's executor if one is specified.default java.util.concurrent.CompletionStage<T>getBody()Returns the body'sCompletionStage.
-
-
-
Method Detail
-
encoding
java.lang.String encoding()
Returns the encoding used by this decoder. This corresponds to the value of theContent-Typeheader.
-
executor
java.util.Optional<java.util.concurrent.Executor> executor()
Returns this decoder's executor if one is specified.
-
downstream
java.net.http.HttpResponse.BodySubscriber<T> downstream()
Returns this decoder's downstream.
-
-