Package org.springframework.http.client
Interface AsyncClientHttpRequestInterceptor
public interface AsyncClientHttpRequestInterceptor
Intercepts client-side HTTP requests. Implementations of this interface can be registered with theAsyncRestTemplate
as to modify the outgoingHttpRequest
and/or register to modify the incomingClientHttpResponse
with help of aListenableFutureAdapter
.The main entry point for interceptors is
intercept(org.springframework.http.HttpRequest, byte[], org.springframework.http.client.AsyncClientHttpRequestExecution)
.- Since:
- 4.3
- Author:
- Jakub Narloch, Rossen Stoyanchev
- See Also:
AsyncRestTemplate
,InterceptingAsyncHttpAccessor
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ListenableFuture<ClientHttpResponse>
intercept(HttpRequest request, byte[] body, AsyncClientHttpRequestExecution execution)
Intercept the given request, and return a response future.
Method Detail
intercept
ListenableFuture<ClientHttpResponse> intercept(HttpRequest request, byte[] body, AsyncClientHttpRequestExecution execution) throws IOException
Intercept the given request, and return a response future. The givenAsyncClientHttpRequestExecution
allows the interceptor to pass on the request to the next entity in the chain.An implementation might follow this pattern:
- Examine the request and body
- Optionally wrap the request to filter HTTP attributes.
- Optionally modify the body of the request.
- One of the following:
- execute the request through
ClientHttpRequestExecution
- don't execute the request to block the execution altogether
- execute the request through
- Optionally adapt the response to filter HTTP attributes with the help of
ListenableFutureAdapter
.
- Parameters:
request
- the request, containing method, URI, and headersbody
- the body of the requestexecution
- the request execution- Returns:
- the response future
- Throws:
IOException
- in case of I/O errors