我如何使用Spring5 WebClient支持HTTP代理? [英] How can I support an HTTP Proxy using Spring 5 WebClient?

查看:15
本文介绍了我如何使用Spring5 WebClient支持HTTP代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Spring5 WebClient。我想知道是否可以将它配置为使用HTTP代理,或者是否有方法可以更改它的默认配置来这样做。

推荐答案

这是基础客户端库应该支持的内容。

使用Reator Netty时,您可以执行以下操作:

HttpClient httpClient = HttpClient.create()
            .tcpConfiguration(tcpClient ->
                    tcpClient.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP).host("myproxyhost")));
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
WebClient client = WebClient.builder().clientConnector(connector).build();

这篇关于我如何使用Spring5 WebClient支持HTTP代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆