cancel
Showing results for 
Search instead for 
Did you mean: 

Search web script and warning message in alfresco.log

theorbix
Confirmed Champ
Confirmed Champ
Hello, I've written a Web Script that performs a query and returns the set of results in JSON.

I've noticed that every time I execute the web script, the following warning message is written in alfresco.log:

21-lug-2008 17.13.28 org.apache.commons.httpclient.HttpMethodBase getResponseBody
WARNING: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

What does it mean, in detail?
1 REPLY 1

steventux
Champ in-the-making
Champ in-the-making
This relates to the HttpClient code used. (See HttpClient Apache project for more general info).
The call HttpMethod.getResponseBody() returns a byte[] and given that the reponse could be of substantial length it's advised that you stream the output of the response using HttpMethod.getResponseBodyAsStream() - this way you can read a user defined number of bytes. e.g.


BufferedReader reader =
    new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
StringBuilder result = new StringBuilder();
char[] buffer = new char[4 * 1024];
int charsRead;
while ((charsRead = reader.read(buffer)) != -1) {
    result.append(buffer, 0, charsRead);
}
reader.close();



This is covered in the HttpClient docs.