- java.lang.Object
-
- com.github.mizosoft.methanol.MoreBodyHandlers
-
public class MoreBodyHandlers extends java.lang.ObjectStatic factories for additionalHttpResponse.BodyHandlerimplementations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.net.http.HttpResponse.BodyHandler<T>decoding(java.net.http.HttpResponse.BodyHandler<T> downstreamBodyHandler)Returns aBodyHandlerthat decompresses the response body for the given handler using aBodyDecoder.static <T> java.net.http.HttpResponse.BodyHandler<T>decoding(java.net.http.HttpResponse.BodyHandler<T> downstreamHandler, @Nullable java.util.concurrent.Executor executor)Returns aBodyHandlerthat decompresses the response body for the given handler using aBodyDecoder.static <T,S extends java.util.concurrent.Flow.Subscriber<? super java.util.List<java.nio.ByteBuffer>>>
java.net.http.HttpResponse.BodyHandler<T>fromAsyncSubscriber(S downstream, java.util.function.Function<? super S,? extends java.util.concurrent.CompletionStage<T>> asyncFinisher)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.fromAsyncSubscriber(Subscriber, Function).static java.net.http.HttpResponse.BodyHandler<java.nio.channels.ReadableByteChannel>ofByteChannel()Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofByteChannel().static <T> java.net.http.HttpResponse.BodyHandler<java.util.function.Supplier<T>>ofDeferredObject(TypeRef<T> typeRef)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType).static <T> java.net.http.HttpResponse.BodyHandler<java.util.function.Supplier<T>>ofDeferredObject(java.lang.Class<T> type)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofDeferredObject(TypeRef, MediaType).static <T> java.net.http.HttpResponse.BodyHandler<T>ofObject(TypeRef<T> typeRef)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType).static <T> java.net.http.HttpResponse.BodyHandler<T>ofObject(java.lang.Class<T> type)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType).static java.net.http.HttpResponse.BodyHandler<java.io.Reader>ofReader()Returns aBodyHandlerthat returns a subscriber obtained formMoreBodySubscribers.ofReader(Charset)using the charset specified by theContent-Typeheader, orUTF-8if not present.static java.net.http.HttpResponse.BodyHandler<java.io.Reader>ofReader(java.nio.charset.Charset charset)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofReader(Charset)using the given charset.static <T> java.net.http.HttpResponse.BodyHandler<T>withReadTimeout(java.net.http.HttpResponse.BodyHandler<T> delegate, java.time.Duration timeout)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration).static <T> java.net.http.HttpResponse.BodyHandler<T>withReadTimeout(java.net.http.HttpResponse.BodyHandler<T> delegate, java.time.Duration timeout, java.util.concurrent.ScheduledExecutorService scheduler)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration, ScheduledExecutorService).
-
-
-
Method Detail
-
fromAsyncSubscriber
public static <T,S extends java.util.concurrent.Flow.Subscriber<? super java.util.List<java.nio.ByteBuffer>>> java.net.http.HttpResponse.BodyHandler<T> fromAsyncSubscriber(S downstream, java.util.function.Function<? super S,? extends java.util.concurrent.CompletionStage<T>> asyncFinisher)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.fromAsyncSubscriber(Subscriber, Function).
-
withReadTimeout
public static <T> java.net.http.HttpResponse.BodyHandler<T> withReadTimeout(java.net.http.HttpResponse.BodyHandler<T> delegate, java.time.Duration timeout)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration).
-
withReadTimeout
public static <T> java.net.http.HttpResponse.BodyHandler<T> withReadTimeout(java.net.http.HttpResponse.BodyHandler<T> delegate, java.time.Duration timeout, java.util.concurrent.ScheduledExecutorService scheduler)Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.withReadTimeout(BodySubscriber, Duration, ScheduledExecutorService).
-
ofByteChannel
public static java.net.http.HttpResponse.BodyHandler<java.nio.channels.ReadableByteChannel> ofByteChannel()
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofByteChannel(). The response is completed as soon as headers are received.
-
ofReader
public static java.net.http.HttpResponse.BodyHandler<java.io.Reader> 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
public static java.net.http.HttpResponse.BodyHandler<java.io.Reader> ofReader(java.nio.charset.Charset charset)
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofReader(Charset)using the given charset. The response is completed as soon as headers are received.
-
ofObject
public static <T> java.net.http.HttpResponse.BodyHandler<T> ofObject(java.lang.Class<T> type)
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType). The media type is parsed from theContent-Typeresponse header if present.- Throws:
java.lang.UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
ofObject
public static <T> java.net.http.HttpResponse.BodyHandler<T> ofObject(TypeRef<T> typeRef)
Returns aBodyHandlerthat returns a subscriber obtained fromMoreBodySubscribers.ofObject(TypeRef, MediaType). The media type is parsed from theContent-Typeresponse header if present.- Throws:
java.lang.UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
ofDeferredObject
public static <T> java.net.http.HttpResponse.BodyHandler<java.util.function.Supplier<T>> ofDeferredObject(java.lang.Class<T> type)
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:
java.lang.UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
ofDeferredObject
public static <T> java.net.http.HttpResponse.BodyHandler<java.util.function.Supplier<T>> ofDeferredObject(TypeRef<T> typeRef)
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:
java.lang.UnsupportedOperationException- if noBodyAdapter.Decoderthat supports the given type is installed
-
decoding
public static <T> java.net.http.HttpResponse.BodyHandler<T> decoding(java.net.http.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> java.net.http.HttpResponse.BodyHandler<T> decoding(java.net.http.HttpResponse.BodyHandler<T> downstreamHandler, @Nullable java.util.concurrent.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.
-
-