Hello All,

as said in the issue 357 [1], this problem is due to the fact that when using the Apache HTTPClient the response must be fully read (see also HTTPClient tutorial [2]) . As this task cannot be automated by the framework, this has to be done explicitly by the users. In next release 1.1, a "release" method will be provided (which does not avoid users to call it explicitly).
Web documentation and javadocs will be updated.

best regards,
Thierry Boileau

[1] http://restlet.tigris.org/issues/show_bug.cgi?id=357
[2] http://jakarta.apache.org/httpcomponents/httpclient-3.x/tutorial.html
Hi,

first of all, kudos for your great work. We are using your framework intensively in our production environment and it works like a charm.

I have stumbled with an issue with org.restlet.Client, that you might be able to solve. We need to navigate through a website and retrieve a csv file in a 3-step process: + POST some credentials, inspect the response for a redirect, + GET to the redirect and + GET to a csv resource.

This is the code that hangs in the last GET for the csv file:

Form form = new Form();
form.add("organizationId", "xxxxx");
form.add("username", "CCCC");
form.add("password", "VVVVV");

Client ebcClient = new Client(Protocol.HTTPS);
Response loginResponse =
ebcClient.post("https://xxxxxxx.com/ebctest/login/LoginProcess.do";,
form.getWebRepresentation());
Reference reference = loginResponse.getRedirectRef();
ebcClient.get(reference);
String yearMonthDay = "2007/08/28";
Response reportResponse =
ebcClient.get("https://xxxxxx/DownloadReport/"+yearMonthDay+
"/overstock_test/PaymentBatchDetailReport.csv");


However the following equivalent code works perfectly fine:


HttpClient httpClient = new HttpClient();
PostMethod httpLoginPost = new
PostMethod("https://xxxxx/ebctest/login/LoginProcess.do";);
NameValuePair[] postData = {
 new NameValuePair("organizationId", "xxxxxx"),
 new NameValuePair("username", "xxxxxx"),
 new NameValuePair("password", "xxxxxx")
};

httpLoginPost.setRequestBody(postData);
httpClient.executeMethod(httpLoginPost);

String redirectLocation = 
httpLoginPost.getResponseHeader("location").getValue();
GetMethod getLogin = new GetMethod(redirectLocation);
httpClient.executeMethod(getLogin);

String yearMonthDay = "2007/08/28";
GetMethod csvGet = new
GetMethod("https://xxxxxx/ebctest/DownloadReport/"+yearMonthDay+
"/overstock_test/PaymentBatchDetailReport.csv");

httpClient.executeMethod(csvGet);

BufferedReader in = new BufferedReader(new
InputStreamReader(csvGet.getResponseBodyAsStream()));

    String line;
    while((line = in.readLine()) != null) {
      logger.debug(line);
    }
httpLoginPost.releaseConnection();
getLogin.releaseConnection();


This is the log where the org.restlet.Client hangs :

2007-08-31 09:25:49,303 [main] DEBUG
org.apache.commons.httpclient.HttpMethodBase - enter
HttpMethodBase.processResponseHeaders(HttpState, HttpConnection)
2007-08-31 09:25:49,303 [main] DEBUG
org.apache.commons.httpclient.HttpMethodBase - enter
HttpMethodBase.processCookieHeaders(Header[], HttpState, HttpConnection)
2007-08-31 09:25:49,303 [main] DEBUG
org.apache.commons.httpclient.HttpMethodBase - enter
HttpMethodBase.readResponseBody(HttpState, HttpConnection)
2007-08-31 09:25:49,304 [main] DEBUG
org.apache.commons.httpclient.HttpMethodBase - enter HttpMethodBase.readResponseBody(HttpConnection)
2007-08-31 09:25:49,304 [main] DEBUG
org.apache.commons.httpclient.HttpConnection - enter HttpConnection.getResponseInputStream()
2007-08-31 09:25:49,304 [main] DEBUG
org.apache.commons.httpclient.HttpMethodBase - enter HttpMethodBase.canResponseHaveBody(int)
2007-08-31 09:25:49,304 [main] DEBUG
org.apache.commons.httpclient.HttpMethodDirector - Redirect required
2007-08-31 09:25:55,324 [main] DEBUG
org.apache.commons.httpclient.methods.GetMethod - enter GetMethod(String)
2007-08-31 09:25:55,325 [main] DEBUG org.apache.commons.httpclient.HttpClient  -

enter HttpClient.executeMethod(HttpMethod)
2007-08-31 09:25:55,325 [main] DEBUG org.apache.commons.httpclient.HttpClient  -

enter HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)
2007-08-31 09:25:55,326 [main] DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager -
enter HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)
2007-08-31 09:25:55,326 [main] DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager  -

HttpConnectionManager.getConnection:  config =
HostConfiguration[host=https://ebctest.cybersource.com], timeout = 0
2007-08-31 09:25:55,326 [main] DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager - enter HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)
2007-08-31 09:25:55,326 [main] DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager - Unable to get a connection, waiting...,
hostConfig=HostConfiguration[host=https://ebctest.cybersource.com]



Thanks

/Nic

Reply via email to