> Which system properties did you set, so I can reproduce your setup with a
proxy server here?

The following system properties were set :

System.setProperty("http.proxyHost","web-proxy");
System.setProperty("http.proxyPort","8080");

The code works fine when using HttpClient directly(proxy settings done using
SimpleHttpConnectionManager class). But there is no class/method in the Restlet
HttpClient connector that provides proxy settings methods.

The working code using HttpClient directly is as follows :

SimpleHttpConnectionManager connectionManager = new
SimpleHttpConnectionManager(); HttpClient client = new
HttpClient(connectionManager); HostConfiguration config =
client.getHostConfiguration();
config.setProxy("web-proxy", 8080);               
   
// Create a method instance.
GetMethod method = new GetMethod(uri);
            
// Provide custom retry handler is necessary
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, 
                        new DefaultHttpMethodRetryHandler(3, false));

try {
      // Execute the method.
      int statusCode = client.executeMethod(method);

      if (statusCode != HttpStatus.SC_OK) {
        System.err.println("Method failed: " + method.getStatusLine());
      }
      // Read the response body.
      byte[] responseBody = method.getResponseBody();

      // Deal with the response.
      // Use caution: ensure correct character encoding and is not binary data
      System.out.println(new String(responseBody));

    } catch (HttpException e) {
      System.err.println("Fatal protocol violation: " + e.getMessage());
      e.printStackTrace();
    } catch (IOException e) {
      System.err.println("Fatal transport error: " + e.getMessage());
      e.printStackTrace();
    } finally {
      // Release the connection.
      method.releaseConnection();
    }  

Thanks
Thara








Reply via email to