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 ofExchangeFilterFunction
for basic authentication, error handling, etc.- Since:
- 5.0
- Author:
- Rob Winch, Arjen Poutsma, Sam Brannen
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExchangeFilterFunctions.Credentials
Deprecated.as of Spring 5.1 in favor of usingHttpHeaders.setBasicAuth(String, String)
while building the request.
Field Summary
Fields Modifier and Type Field Description static String
BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE
Deprecated.as of Spring 5.1 in favor of usingHttpHeaders.setBasicAuth(String, String)
while building the request.
Constructor Summary
Constructors Constructor Description ExchangeFilterFunctions()
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ExchangeFilterFunction
basicAuthentication()
Deprecated.as of Spring 5.1 in favor of usingHttpHeaders.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 viaHttpHeaders.setBasicAuth(String)
andHttpHeaders.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<HttpStatus> statusPredicate, Function<ClientResponse,? extends Throwable> exceptionFunction)
Return a filter that generates an error signal when the givenHttpStatus
predicate matches.
Field Detail
BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE
@Deprecated public static final String BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE
Deprecated.as of Spring 5.1 in favor of usingHttpHeaders.setBasicAuth(String, String)
while building the request.Name of the request attribute withExchangeFilterFunctions.Credentials
forbasicAuthentication()
.
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<HttpStatus> statusPredicate, Function<ClientResponse,? extends Throwable> exceptionFunction)
Return a filter that generates an error signal when the givenHttpStatus
predicate matches.- Parameters:
statusPredicate
- the predicate to check the HTTP status withexceptionFunction
- 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 viaHttpHeaders.setBasicAuth(String)
andHttpHeaders.encodeBasicAuth(String, String, Charset)
.- Parameters:
username
- the usernamepassword
- 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 usingHttpHeaders.setBasicAuth(String, String)
while building the request.Variant ofbasicAuthentication(String, String)
that looks up theCredentials
in arequest attribute
.- Returns:
- the filter to use
- See Also:
ExchangeFilterFunctions.Credentials