I tried to get a web page through a proxy server who require user authentication.
Although I set correctly the user and the password in the ConnectionManager with the methods setProxyUser() and setProxyPassword() the proxy always report the following error:
407 Proxy Authentication Required.
I am using HTMLParser Version 1.6 (Release Build Jun 10, 2006) and Squid Proxy Server.
Using Ethereal software I compared the messages sent by HTMLParser and Microsoft Internet Explorer during the proxy authentication and I found a difference that you can see
HTMLParser: Proxy-Authorization: Z2VsbWV0dGk6Z2VsbWV0dGk=\r\n
IE: Proxy-Authorization: Basic Z2VsbWV0dGk6Z2VsbWV0dGk=\r\n
Solution:
I modified the method ‘openConnection’ in the ‘ConnectionManager’ class adding the string ‘Basic ‘ as I show in the following code:
// set the proxy name and password
if ((null != getProxyUser ())
&& (null != getProxyPassword ()))
{
auth = getProxyUser () + ":" + getProxyPassword ();
encoded = encode (auth.getBytes("ISO-8859-1"));
ret.setRequestProperty ("Proxy-Authorization", "Basic " + encoded);
}
After that I rebuild the software and I tested it with success.
I attach the file modified.
Regards.
Jorge Gelmetti
ConnectionManager modified
Logged In: YES
user_id=605407
Originator: NO
Add "Basic " prefix to Proxy-Authorization request property.