重定向
RestClient
的重定向功能通过底层的HttpClient
来实现,可以分别支持 Client 级别 及 Request 级别。默认最大重定向次数为5。Client级别重定向
Client级别的重定向将对该Client下的所有 Request 生效,具体配置方式如下:
final RestClient client = RestClient.create()
.maxRedirects(3)
.build();
Request级别重定向
当Request设置了重定向次数,其数据将覆盖Client设置的重定向次数,具体配置方式如下:
final RestClient client = RestClient.ofDefault();
final String entity = client.get("http://127.0.0.1:8081/")
.maxRedirects(3)
.execute()
.toCompletableFuture()
.get()
.bodyToEntity(String.class);
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified April 22, 2022: add docs about traffic-split (34b84ce)