commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Iker Bilbao <ib...@tid.es>
Subject [httpclient] Get through a proxy problem
Date Tue, 29 Apr 2003 07:40:27 GMT
Hello,

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

  Here is my code:
  -------------------
  Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
  System.getProperties().put("java.protocol.handler.pkgs", "org.apache.commons.httpclient.HttpClient");
  System.setProperty("javax.net.ssl.trustStore","C:\\.keystore");
  System.setProperty("javax.net.ssl.keyStore","C:\\.keystore");
  System.setProperty("javax.net.ssl.keyStorePassword","password");

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

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

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

So I added the following lines:

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

And I got the following error:

    HTTP/1.0 500 Server Error

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.

I have tryed a workaround I have read I the example archive called:
CustomHttpConnection.java

And I always get and error or a null response.

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

Thanks in advance por your help.
Iker


Mime
View raw message