Class RxJavaHttpClient

  • All Implemented Interfaces:
    RxHttpClient, java.io.Closeable, java.lang.AutoCloseable

    public class RxJavaHttpClient
    extends BaseRxHttpClient
    implements RxHttpClient
    A Reactive HTTP Client Created by Karel Maesen, Geovise BVBA on 05/12/14.
    • Method Detail

      • executeToCompletion

        public <F> io.reactivex.rxjava3.core.Flowable<F> executeToCompletion​(ClientRequest request,
                                                                             java.util.function.Function<ServerResponse,​F> transformer)
        Executes a request and returns an Observable for the complete response.

        The returned Observable is Cold, i.e. on each subscription a new HTTP request is made and the response elements returned as a new Observable. So for each subscriber, a separate HTTP request will be made.

        Specified by:
        executeToCompletion in interface RxHttpClient
        Type Parameters:
        F - the type of return value
        Parameters:
        request - the request to send
        transformer - a function that transforms the ServerResponse to a value of F
        Returns:
        An Observable that returns the transformed server response.
      • executeObservably

        public io.reactivex.rxjava3.core.Flowable<ServerResponseElement> executeObservably​(ClientRequest request)
        Returns a "cold" Observable for a stream of ServerResponseElements.

        The returned Observable is Cold, i.e. on each subscription a new HTTP request is made and the response elements returned as a new Observable. So for each subscriber, a separate HTTP request will be made.

        Specified by:
        executeObservably in interface RxHttpClient
        Parameters:
        request - the request to send
        Returns:
        a cold observable of ServerResponseElements
        See Also:
        Observable.defer(io.reactivex.rxjava3.functions.Supplier<? extends io.reactivex.rxjava3.core.ObservableSource<? extends T>>)
      • executeAndDechunk

        public io.reactivex.rxjava3.core.Flowable<java.lang.String> executeAndDechunk​(ClientRequest request,
                                                                                      java.lang.String separator)
        Returns a "cold" Observable for a stream of messages.

        All ServerResponseElements are filtered out, ResponseBodyParts are turned into (UTF8) Strings, and the chunks are combined and split at the specified separator characters.

        The returned Observable is Cold, i.e. on each subscription a new HTTP request is made and the response elements returned as a new Observable. So for each subscriber, a separate HTTP request will be made.

        Specified by:
        executeAndDechunk in interface RxHttpClient
        Overrides:
        executeAndDechunk in class BaseRxHttpClient
        Parameters:
        request - the request to send
        separator - the separator
        Returns:
        a cold Flowable of messages (UTF8 Strings)
      • executeAndDechunk

        public io.reactivex.rxjava3.core.Flowable<java.lang.String> executeAndDechunk​(ClientRequest request,
                                                                                      java.lang.String separator,
                                                                                      java.nio.charset.Charset charset)
        Returns a "cold" Observable for a stream of messages.

        All ServerResponseElements are filtered out, ResponseBodyParts are turned into Strings in the specified charset, and the chunks are combined and split at the separator characters.

        The returned Observable is Cold, i.e. on each subscription a new HTTP request is made and the response elements returned as a new Observable. So for each subscriber, a separate HTTP request will be made.

        Specified by:
        executeAndDechunk in interface RxHttpClient
        Parameters:
        request - the request to send
        separator - the separator
        charset - the character set of the messages
        Returns:
        a cold Flowable of messages (Strings in the specified Charset)
      • executeObservably

        public <F> io.reactivex.rxjava3.core.Flowable<F> executeObservably​(ClientRequest request,
                                                                           java.util.function.Function<byte[],​F> transform)
        Returns a "cold" Observable for a stream of T.

        The returned Observable is Cold, i.e. on each subscription a new HTTP request is made and the response elements returned as a new Observable. So for each subscriber, a separate HTTP request will be made.

        Specified by:
        executeObservably in interface RxHttpClient
        Type Parameters:
        F - return type of the transform
        Parameters:
        request - the request to send
        transform - the function that transforms the response body (chunks) into objects of type F
        Returns:
        a cold observable of ServerResponseElements
        See Also:
        Observable.defer(io.reactivex.rxjava3.functions.Supplier<? extends io.reactivex.rxjava3.core.ObservableSource<? extends T>>)