接口 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)
.- 从以下版本开始:
- 4.3
- 作者:
- Jakub Narloch, Rossen Stoyanchev
- 另请参阅:
AsyncRestTemplate
,InterceptingAsyncHttpAccessor
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 ListenableFuture<ClientHttpResponse>
intercept(HttpRequest request, byte[] body, AsyncClientHttpRequestExecution execution)
Intercept the given request, and return a response future.
方法详细资料
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
.
- 参数:
request
- the request, containing method, URI, and headersbody
- the body of the requestexecution
- the request execution- 返回:
- the response future
- 抛出:
IOException
- in case of I/O errors