Class ExchangeFilterFunctions

java.lang.Object
org.springframework.web.reactive.function.client.ExchangeFilterFunctions

public abstract class ExchangeFilterFunctions extends Object
Static factory methods providing access to built-in implementations of ExchangeFilterFunction for basic authentication, error handling, etc.
Since:
5.0
Author:
Rob Winch, Arjen Poutsma, Sam Brannen
  • Constructor Details

    • ExchangeFilterFunctions

      public ExchangeFilterFunctions()
  • Method Details

    • limitResponseSize

      public static ExchangeFilterFunction limitResponseSize(long maxByteCount)
      Consume up to the specified number of bytes from the response body and cancel if any more data arrives.

      Internally delegates to DataBufferUtils.takeUntilByteCount(org.reactivestreams.Publisher<T>, long).

      Parameters:
      maxByteCount - the limit as number of bytes
      Returns:
      the filter to limit the response size with
      Since:
      5.1
    • statusError

      public static ExchangeFilterFunction statusError(Predicate<org.springframework.http.HttpStatusCode> statusPredicate, Function<ClientResponse,? extends Throwable> exceptionFunction)
      Return a filter that generates an error signal when the given HttpStatusCode predicate matches.
      Parameters:
      statusPredicate - the predicate to check the HTTP status with
      exceptionFunction - the function to create the exception
      Returns:
      the filter to generate an error signal
    • basicAuthentication

      public static ExchangeFilterFunction basicAuthentication(String username, String password)
      Return a filter that applies HTTP Basic Authentication to the request headers via HttpHeaders.setBasicAuth(String) and HttpHeaders.encodeBasicAuth(String, String, Charset).
      Parameters:
      username - the username
      password - the password
      Returns:
      the filter to add authentication headers with
      See Also:
      • HttpHeaders.encodeBasicAuth(String, String, Charset)
      • HttpHeaders.setBasicAuth(String)
    • basicAuthentication

      @Deprecated public static ExchangeFilterFunction basicAuthentication()
      Deprecated.
      as of Spring 5.1 in favor of using HttpHeaders.setBasicAuth(String, String) while building the request.
      Variant of basicAuthentication(String, String) that looks up the Credentials in a request attribute.
      Returns:
      the filter to use
      See Also: