我创建了一个基本的REST控制器,它使用netty在Spring-boot 2中使用被动Webclient进行请求.
@RestController
@RequestMapping("/test")
@Log4j2
public class TestController {
private WebClient client;
@PostConstruct
public void setup() {
client = WebClient.builder()
.baseUrl("http://www.google.com/")
.exchangeStrategies(ExchangeStrategies.withDefaults())
.build();
}
@GetMapping
public Mono<String> hello() throws URISyntaxException {
return client.get().retrieve().bodyToMono(String.class);
}
}
Run Code Online (Sandbox Code Playgroud)
当我收到3XX响应代码时,我希望webclient使用响应中的Location来跟踪重定向,并递归调用该URI,直到我得到非3XX响应.
我得到的实际结果是3XX响应.