接口 ClientHttpRequestInterceptor
- 所有已知实现类:
BasicAuthenticationInterceptor
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
Intercepts client-side HTTP requests. Implementations of this interface can be
registered
with the
RestTemplate,
as to modify the outgoing ClientHttpRequest and/or the incoming
ClientHttpResponse.
The main entry point for interceptors is
intercept(HttpRequest, byte[], ClientHttpRequestExecution).
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma
-
方法概要
修饰符和类型方法说明intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) Intercept the given request, and return a response.
-
方法详细资料
-
intercept
ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException Intercept the given request, and return a response. The givenClientHttpRequestExecutionallows the interceptor to pass on the request and response to the next entity in the chain.A typical implementation of this method would follow the following pattern:
- Examine the request and body.
- Optionally wrap the request to filter HTTP attributes.
- Optionally modify the body of the request.
- Either
- execute the request using
ClientHttpRequestExecution.execute(cn.taketoday.http.HttpRequest, byte[]), - or
- do not execute the request to block the execution altogether.
- Optionally wrap the response to filter HTTP attributes.
- 参数:
request- the request, containing method, URI, and headersbody- the body of the requestexecution- the request execution- 返回:
- the response
- 抛出:
IOException- in case of I/O errors
-