如何配置HTTPClient以对SOCKS代理进行身份验证? [英] How can I configure HTTPClient to authenticate against a SOCKS proxy?

查看:155
本文介绍了如何配置HTTPClient以对SOCKS代理进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要针对SOCKS代理设置代理身份验证。
我发现了这篇文章提供了似乎适用于常见HTTP代理的说明。

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.

        httpclient.getHostConfiguration().setProxy("proxyserver.example.com", 8080);

        HttpState state = new HttpState();
        state.setProxyCredentials(new AuthScope("proxyserver.example.com", 8080), 
           new UsernamePasswordCredentials("username", "password"));
        httpclient.setState(state);

这也适用于 SOCKS 代理或我是否必须这样做不同的东西?

Would that work with SOCKS proxies as well or do I have to do something different?

推荐答案

功能页面说:


通过SOCKS代理的透明连接(版本4& 5)使用本机Java套接字支持。

Transparent connections through SOCKS proxies (version 4 & 5) using native Java socket support.

使用透明,我猜他们的意思是它可以在没有你需要的情况下工作做任何特别的事。你在某处有SOCKS代理吗?难道你不能试一试看它是否有效吗?

With "transparent", I guess they mean that it works without you needing to do anything special. Do you have a SOCKS proxy available somewhere? Can't you just try it out to see if it works?

这篇关于如何配置HTTPClient以对SOCKS代理进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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