Note that there are some explanatory texts on larger screens.

plurals
  1. POJava HttpClient or PostMethod truncating return data to 64k
    text
    copied!<p>I'm using Apache Commons HttpClient to grab some data from a server. My problem is that the returned XML data is always truncated to the first 64k. I was hoping this might just be a case of setting a limit on the relevant object, but apparently not - or at least, I can't find any information about such a method. I'm assuming it's a client issue as the server belongs to another company and presumably serves the data fine to everyone else.</p> <p>Any ideas?</p> <p>My code btw is super simple:</p> <pre><code>protected String send(Server server, String query) throws Exception { PostMethod post = new PostMethod(server.getUrl()); post.setParameter("XMLString", query); try { client.executeMethod(post); return post.getResponseBodyAsString(); } finally { post.releaseConnection(); } } </code></pre> <p>fyi, same thing happens with the following code using InputStreams rather than the getResponseBodyAsString() method.</p> <pre><code>protected String send(Server server, String query) throws Exception { PostMethod post = new PostMethod(server.getUrl()); post.setParameter("XMLString", query); try { client.executeMethod(post); InputStream stream = post.getResponseBodyAsStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line = null; StringBuilder sb = new StringBuilder(); while ( (line=reader.readLine()) != null ) { sb.append(line); } return sb.toString(); } finally { post.releaseConnection(); } } </code></pre> <p>So, do you know if there is a limit set somewhere? The fact that the String is response is <em>always</em> 64k does seem to suggest there must be. But where?!</p> <p>Thanks</p> <p>Alastair</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload