Class ExchangeFilterFunctions
java.lang.Object
org.springframework.web.reactive.function.client.ExchangeFilterFunctions
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 ClassesModifier and TypeClassDescriptionstatic final classDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExchangeFilterFunctionDeprecated.as of Spring 5.1 in favor of usingHttpHeaders.setBasicAuth(String, String)while building the request.static ExchangeFilterFunctionbasicAuthentication(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 ExchangeFilterFunctionlimitResponseSize(long maxByteCount) Consume up to the specified number of bytes from the response body and cancel if any more data arrives.static ExchangeFilterFunctionstatusError(Predicate<HttpStatus> statusPredicate, Function<ClientResponse, ? extends Throwable> exceptionFunction) Return a filter that generates an error signal when the givenHttpStatuspredicate matches.
-
Constructor Details
-
ExchangeFilterFunctions
public ExchangeFilterFunctions()
-
-
Method Details
-
limitResponseSize
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 givenHttpStatuspredicate 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
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:
-
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 theCredentialsin arequest attribute.- Returns:
- the filter to use
- See Also:
-
HttpHeaders.setBasicAuth(String, String)while building the request.