How can I support an HTTP Proxy using Spring 5 WebClient?

﹥>﹥吖頭↗ 提交于 2019-12-12 07:48:44

问题


I am using Spring 5 WebClient. I want to know if it is possible to configure it to use an HTTP Proxy, or if there is a way of changing it's default configuration to do so.


回答1:


This is something that the underlying client library should support.

When using Reactor Netty, you can do something like:

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();


来源:https://stackoverflow.com/questions/46979982/how-can-i-support-an-http-proxy-using-spring-5-webclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!