Class MoreBodyHandlers
java.lang.Object
com.github.mizosoft.methanol.MoreBodyHandlers
Static factories for additional
HttpResponse.BodyHandler implementations.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> HttpResponse.BodyHandler<T> decoding(HttpResponse.BodyHandler<T> downstreamBodyHandler) Returns aBodyHandlerthat decompresses the response body for the given handler using aBodyDecoder.static <T> HttpResponse.BodyHandler<T> decoding(HttpResponse.BodyHandler<T> downstreamHandler, @Nullable Executor executor) Returns aBodyHandlerthat 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 aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.fromAsyncSubscriber(Subscriber, Function).Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofByteChannel().static <T> HttpResponse.BodyHandler<Supplier<T>> ofDeferredObject(TypeRef<T> typeRef) Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType).static <T> HttpResponse.BodyHandler<Supplier<T>> ofDeferredObject(Class<T> type) Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType).static <T> HttpResponse.BodyHandler<T> Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType).static <T> HttpResponse.BodyHandler<T> Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType).static HttpResponse.BodyHandler<Reader> ofReader()Returns aBodyHandlerthat returns a subscriber obtained formMoreBodySubscribers.ofReader(Charset)using the charset specified by theContent-Typeheader, orUTF-8if not present.static HttpResponse.BodyHandler<Reader> Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofReader(Charset)using the given charset.static <T> HttpResponse.BodyHandler<T> withReadTimeout(HttpResponse.BodyHandler<T> delegate, Duration timeout) Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration).static <T> HttpResponse.BodyHandler<T> withReadTimeout(HttpResponse.BodyHandler<T> delegate, Duration timeout, ScheduledExecutorService scheduler) Returns aBodyHandlerthat 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 aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.fromAsyncSubscriber(Subscriber, Function). -
withReadTimeout
public static <T> HttpResponse.BodyHandler<T> withReadTimeout(HttpResponse.BodyHandler<T> delegate, Duration timeout) Returns aBodyHandlerthat 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 aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration, ScheduledExecutorService). -
ofByteChannel
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofByteChannel(). The response is completed as soon as headers are received. -
ofReader
Returns aBodyHandlerthat returns a subscriber obtained formMoreBodySubscribers.ofReader(Charset)using the charset specified by theContent-Typeheader, orUTF-8if not present. The response is completed as soon as headers are received. -
ofReader
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofReader(Charset)using the given charset. The response is completed as soon as headers are received. -
ofObject
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType). The media type is parsed from theContent-Typeresponse header if present.- Throws:
UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
ofObject
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType). The media type is parsed from theContent-Typeresponse header if present.- Throws:
UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
ofDeferredObject
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType). The media type is parsed from theContent-Typeresponse header if present. The response is completed as soon as headers are received.- Throws:
UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
ofDeferredObject
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType). The media type is parsed from theContent-Typeresponse header if present. The response is completed as soon as headers are received.- Throws:
UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
decoding
public static <T> HttpResponse.BodyHandler<T> decoding(HttpResponse.BodyHandler<T> downstreamBodyHandler) Returns aBodyHandlerthat decompresses the response body for the given handler using aBodyDecoder. The decoder is created using the factory corresponding to the response'sContent-Encodingheader, throwing anUnsupportedOperationExceptionif 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-EncodingandContent-Lengthheaders are stripped before forwarding theResponseInfoto the given handler. -
decoding
public static <T> HttpResponse.BodyHandler<T> decoding(HttpResponse.BodyHandler<T> downstreamHandler, @Nullable Executor executor) Returns aBodyHandlerthat decompresses the response body for the given handler using aBodyDecoder. The decoder is created using the factory corresponding to the response'sContent-Encodingheader, throwing anUnsupportedOperationExceptionif 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-EncodingandContent-Lengthheaders are stripped before forwarding theResponseInfoto the given handler.
-