java.lang.Object
com.github.mizosoft.methanol.MoreBodyHandlers
Factory for additional
HttpResponse.BodyHandler
implementations.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> HttpResponse.BodyHandler
<T> decoding
(HttpResponse.BodyHandler<T> downstreamBodyHandler) Returns aBodyHandler
that decompresses the response body for the given handler using aBodyDecoder
.static <T> HttpResponse.BodyHandler
<T> decoding
(HttpResponse.BodyHandler<T> downstreamHandler, @Nullable Executor executor) Returns aBodyHandler
that decompresses the response body for the given handler using aBodyDecoder
.static <T,
S extends Flow.Subscriber<? super List<ByteBuffer>>>
HttpResponse.BodyHandler<T> fromAsyncSubscriber
(S downstream, Function<? super S, ? extends CompletionStage<T>> asyncFinisher) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.fromAsyncSubscriber(Subscriber, Function)
.Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofByteChannel()
.static <T> HttpResponse.BodyHandler
<Supplier<T>> ofDeferredObject
(TypeRef<T> type) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType)
.static <T> HttpResponse.BodyHandler
<Supplier<T>> ofDeferredObject
(Class<T> type) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType)
.static <T> HttpResponse.BodyHandler
<T> Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType)
.static <T> HttpResponse.BodyHandler
<T> Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType)
.static HttpResponse.BodyHandler
<Reader> ofReader()
Returns aBodyHandler
that returns a subscriber obtained formMoreBodySubscribers.ofReader(Charset)
using the charset specified by theContent-Type
header, orUTF-8
if not present.static HttpResponse.BodyHandler
<Reader> Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofReader(Charset)
using the given charset.static <T> HttpResponse.BodyHandler
<T> withReadTimeout
(HttpResponse.BodyHandler<T> delegate, Duration timeout) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration)
.static <T> HttpResponse.BodyHandler
<T> withReadTimeout
(HttpResponse.BodyHandler<T> delegate, Duration timeout, ScheduledExecutorService scheduler) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration, ScheduledExecutorService)
.
-
Method Details
-
fromAsyncSubscriber
public static <T,S extends Flow.Subscriber<? super List<ByteBuffer>>> HttpResponse.BodyHandler<T> fromAsyncSubscriber(S downstream, Function<? super S, ? extends CompletionStage<T>> asyncFinisher) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.fromAsyncSubscriber(Subscriber, Function)
. -
withReadTimeout
public static <T> HttpResponse.BodyHandler<T> withReadTimeout(HttpResponse.BodyHandler<T> delegate, Duration timeout) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration)
. -
withReadTimeout
public static <T> HttpResponse.BodyHandler<T> withReadTimeout(HttpResponse.BodyHandler<T> delegate, Duration timeout, ScheduledExecutorService scheduler) Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration, ScheduledExecutorService)
. -
ofByteChannel
Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofByteChannel()
. The response is completed as soon as headers are received. -
ofReader
Returns aBodyHandler
that returns a subscriber obtained formMoreBodySubscribers.ofReader(Charset)
using the charset specified by theContent-Type
header, orUTF-8
if not present. The response is completed as soon as headers are received. -
ofReader
Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofReader(Charset)
using the given charset. The response is completed as soon as headers are received. -
ofObject
Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType)
. The media type is parsed from theContent-Type
response header if present.- Throws:
UnsupportedOperationException
- if noBodyAdapter.Decoder
that supports the given type is installed
-
ofObject
Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType)
. The media type is parsed from theContent-Type
response header if present.- Throws:
UnsupportedOperationException
- if noBodyAdapter.Decoder
that supports the given type is installed
-
ofDeferredObject
Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType)
. The media type is parsed from theContent-Type
response header if present. The response is completed as soon as headers are received.- Throws:
UnsupportedOperationException
- if noBodyAdapter.Decoder
that supports the given type is installed
-
ofDeferredObject
Returns aBodyHandler
that returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType)
. The media type is parsed from theContent-Type
response header if present. The response is completed as soon as headers are received.- Throws:
UnsupportedOperationException
- if noBodyAdapter.Decoder
that supports the given type is installed
-
decoding
public static <T> HttpResponse.BodyHandler<T> decoding(HttpResponse.BodyHandler<T> downstreamBodyHandler) Returns aBodyHandler
that decompresses the response body for the given handler using aBodyDecoder
. The decoder is created using the factory corresponding to the response'sContent-Encoding
header, throwing anUnsupportedOperationException
if no such factory is installed. If the header is not present, the result of the given handler is returned as is.If the response is compressed, the
Content-Encoding
andContent-Length
headers are stripped before forwarding theResponseInfo
to the given handler. -
decoding
public static <T> HttpResponse.BodyHandler<T> decoding(HttpResponse.BodyHandler<T> downstreamHandler, @Nullable Executor executor) Returns aBodyHandler
that decompresses the response body for the given handler using aBodyDecoder
. The decoder is created using the factory corresponding to the response'sContent-Encoding
header, throwing anUnsupportedOperationException
if no such factory is installed. If the header is not present, the result of the given handler is returned as is.If the response is compressed, the
Content-Encoding
andContent-Length
headers are stripped before forwarding theResponseInfo
to the given handler.
-