How can I configure HTTPClient to authenticate against a SOCKS proxy?

前端 未结 5 1329
死守一世寂寞
死守一世寂寞 2021-01-03 04:39

I need to set up proxy authentication against a SOCKS proxy. I found out this post giving instructions that appear to work with common HTTP proxies.

                 


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 04:45

    You can provide a custom socket factory which implements the SOCKS protocol, and register it as your default HTTP protocol handler. This solution has a limitation similar to tuergeist's answer above has - it applies globally, to any HTTP connection you'll establish through HttpClient.

    If you find this a problem, take a look at this correspondence, where Oleg suggests using HttpClient 4.0, but also refers to a possible patch in HostConfiguration class for HttpClient 3.x.

    Another possible solution, which is my personal favorite, is to write a wrapper HTTP proxy to the socks proxy.

提交回复
热议问题