进行http连接可以,但是进行https连接有异常代码如下:
////////////////////////////////////////////////////////////////// if(protocol.toLowerCase().equals("http"))
{
if(proxyDomain!=null&&proxyPort!=null)
{
System.setProperty("proxyHost",proxyDomain);
System.setProperty("proxyPort",proxyPort);
System.out.println("http proxy");
}
}
else if(protocol.toLowerCase().equals("https"))
{
if(proxyDomain!=null&&proxyPort!=null)
{
System.setProperty("https.proxyHost",proxyDomain);
System.setProperty("https.proxyPort",proxyPort);
System.out.println("https proxy"); }
}//////////////////////////////如果代理需要用户名和密码登陆///////////////////////////////////////////
if(proxyUsername!=null&&proxyPassword!=null)
{
System.out.println("begin Set proxyInfo");
String pw=proxyUsername+":"+proxyPassword;
BASE64Encoder encoder= new BASE64Encoder();
String encoderpw="Basic "+encoder.encode(pw.getBytes());
con.setRequestProperty("Proxy-Authorization",encoderpw);
System.out.println("has already Set proxyInfo");
}
异常为:
Unable to tunnel through X.X.X.X. Proxy ret
urns "HTTP/1.0 407 Proxy Authentication Required"
好像是说没有身份验证?如果没有验证为什么HTTP连接可以(在进行http连接时,我把用户名和密码去掉,连接失败,说明用户名和密码已经起作用了)
但是为什么https连接不可以,是不是https连接时,要对用户名和密码做特别的处理??请大虾指教 谢谢
////////////////////////////////////////////////////////////////// if(protocol.toLowerCase().equals("http"))
{
if(proxyDomain!=null&&proxyPort!=null)
{
System.setProperty("proxyHost",proxyDomain);
System.setProperty("proxyPort",proxyPort);
System.out.println("http proxy");
}
}
else if(protocol.toLowerCase().equals("https"))
{
if(proxyDomain!=null&&proxyPort!=null)
{
System.setProperty("https.proxyHost",proxyDomain);
System.setProperty("https.proxyPort",proxyPort);
System.out.println("https proxy"); }
}//////////////////////////////如果代理需要用户名和密码登陆///////////////////////////////////////////
if(proxyUsername!=null&&proxyPassword!=null)
{
System.out.println("begin Set proxyInfo");
String pw=proxyUsername+":"+proxyPassword;
BASE64Encoder encoder= new BASE64Encoder();
String encoderpw="Basic "+encoder.encode(pw.getBytes());
con.setRequestProperty("Proxy-Authorization",encoderpw);
System.out.println("has already Set proxyInfo");
}
异常为:
Unable to tunnel through X.X.X.X. Proxy ret
urns "HTTP/1.0 407 Proxy Authentication Required"
好像是说没有身份验证?如果没有验证为什么HTTP连接可以(在进行http连接时,我把用户名和密码去掉,连接失败,说明用户名和密码已经起作用了)
但是为什么https连接不可以,是不是https连接时,要对用户名和密码做特别的处理??请大虾指教 谢谢
那么在https下对用户名和密码 应该怎样处理?