Skip to content

Support of client interceptors in Spring's AsyncRestTemplate [SPR-12538] #16971

@spring-projects-issues

Description

@spring-projects-issues

Francisco Lozano opened SPR-12538 and commented

It would be really useful if AsyncRestTemplate was capable of handling some async-friendly variant of ClientHttpRequestInterceptor's.

I understand the same interceptors are not possible, because the current interface assumes sync behaviour:
{CODE}
ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException;
{CODE}

But it would be very useful to be able to hook and alter the requests before they are executed. Something like:
{CODE}
HttpRequest intercept(HttpRequest request)
{CODE}
would probably be enough, in order to be able to easily add some headers in a centralized way. The actual execution would be done outside of the scope of the async interceptor - just being able to modify/replace the request would be very useful by itself.


Affects: 4.1.3

Issue Links:

Referenced from: commits 63958ac, 258cc7b, 12969f6

6 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions