org.springframework.web.reactive.function.client

## 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

### Nested Class Summary

Nested Classes
`static class` `ExchangeFilterFunctions.Credentials` Deprecated. as of Spring 5.1 in favor of using `HttpHeaders.setBasicAuth(String, String)` while building the request.

### Field Summary

Fields
`static String` `BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE` Deprecated. as of Spring 5.1 in favor of using `HttpHeaders.setBasicAuth(String, String)` while building the request.

### Constructor Summary

Constructors
Constructor and Description
`ExchangeFilterFunctions()`

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`static ExchangeFilterFunction` `basicAuthentication()` Deprecated. as of Spring 5.1 in favor of using `HttpHeaders.setBasicAuth(String, String)` while building the request.
`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)`.
`static ExchangeFilterFunction` `limitResponseSize(long maxByteCount)` Consume up to the specified number of bytes from the response body and cancel if any more data arrives.
`static ExchangeFilterFunction` `statusError(Predicate<org.springframework.http.HttpStatus> statusPredicate, Function<ClientResponse,? extends Throwable> exceptionFunction)` Return a filter that generates an error signal when the given `HttpStatus` predicate matches.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE

    @Deprecated
    public static final String BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE

Deprecated. as of Spring 5.1 in favor of using `HttpHeaders.setBasicAuth(String, String)` while building the request.
Name of the request attribute with `ExchangeFilterFunctions.Credentials` for `basicAuthentication()`.

### Constructor Detail

#### ExchangeFilterFunctions

    public ExchangeFilterFunctions()

### Method Detail

#### 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<? extends org.springframework.core.io.buffer.DataBuffer>, 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.HttpStatus> statusPredicate,
                                                     Function<ClientResponse,? extends Throwable> exceptionFunction)

Return a filter that generates an error signal when the given `HttpStatus` predicate matches.

Parameters:
  `statusPredicate` - the predicate to check the HTTP status with
  `exceptionFunction` - the function that 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:
  `ExchangeFilterFunctions.Credentials`