commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Iker Bilbao <>
Subject Re[2]: [httpclient] Get through a proxy problem
Date Tue, 29 Apr 2003 14:09:08 GMT
Hola Dave,

Yes, off course. It works perfectly with the browser. It was working
until I had to go through the proxy server. If I send the request to a
machine in my LAN it works. But, when I try to obtain a page from
outside through the proxy I always get an error. The only diference
between two examples are the lines to setup the proxy.

Tuesday, April 29, 2003, 3:22:47 PM, escribió:

TD> Have you tried submitting this request with a regular web browser and proxies set up?
 Just to verify it isn't the HTTPClient?

TD> -Dave

TD> -----Original Message-----
TD> From: Iker Bilbao [] 
TD> Sent: Tuesday, April 29, 2003 2:40 AM
TD> To:
TD> Subject: [httpclient] Get through a proxy problem

TD> Hello,

TD>   IŽm totally desperated. IŽm trying to make a simple get over https.
TD>   Everythings went well until I had to pass through a proxy to make
TD>   the request. This piece of code worked perfectly:

TD>   Here is my code:
TD>   -------------------
TD>   Security.addProvider(new;
TD>   System.getProperties().put("java.protocol.handler.pkgs", "org.apache.commons.httpclient.HttpClient");
TD>   System.setProperty("","C:\\.keystore");
TD>   System.setProperty("","C:\\.keystore");
TD>   System.setProperty("","password");

TD>   HttpClient client = new HttpClient();
TD>   client.getState().setCredentials("realm",new
TD>                                               UsernamePasswordCredentials("user","password"));

TD>   GetMethod get = new getMethod("https://server:1234" +"/index.html");
TD>   get.setDoAuthentication( true );

TD>   try
TD>   {
TD>      int status = client.executeMethod( get );
TD>      System.out.println(status + "\n" + get.getResponseBodyAsString());
TD>   }
TD>   catch (HttpRecoverableException e)
TD>   {
TD>      System.err.println("A recoverable exception occurred, retrying.  " + e.getMessage());
TD>   }
TD>   catch (IOException e)
TD>   {
TD>      System.err.println("Failed to download file.");
TD>      e.printStackTrace();
TD>      System.exit(-1);
TD>   }
TD>   catch (Exception e)
TD>   {
TD>      e.printStackTrace();
TD>   }
TD>   -------------------

TD> So I added the following lines:

TD>    HttpClient client = new HttpClient();
TD>    HostConfiguration hc = new HostConfiguration();
TD>    hc.setProxy(properties.getProperty("hostProxy"),Integer.parseInt(properties.getProperty("portProxy")));
TD>    client.setHostConfiguration(hc);
TD>    client.getState().setCredentials("realm",new UsernamePasswordCredentials("user","password"));

TD> And I got the following error:

TD>     HTTP/1.0 500 Server Error

TD> I have tried with every nightly drop from 19th of April to 28 of April and I always
get and error. Sometimes this or sometimes another. I think that logical the code should be
like this.

TD> I have tryed a workaround I have read I the example archive called:

TD> And I always get and error or a null response.

TD> Please, can anyone give lend a hand? How can I do this?

TD> Thanks in advance por your help.
TD> Iker

TD> ---------------------------------------------------------------------
TD> To unsubscribe, e-mail:
TD> For additional commands, e-mail:


View raw message