小编Mar*_*und的帖子

如何使反应式webclient遵循3XX重定向?

我创建了一个基本的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响应.

spring-boot project-reactor reactor-netty spring-webflux

8
推荐指数
2
解决办法
2517
查看次数