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

前端 未结 1 387
走了就别回头了
走了就别回头了 2021-02-02 12:46

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条回答
  • 2021-02-02 13:26

    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();
    
    0 讨论(0)
提交回复
热议问题