views:

99

answers:

1

I'm trying to use the jakarta commons HttpClient library.

I think I'm being dumb here, but I can't figure out how to write a complete HttpEntity to file.

I'm trying:

FileOutputStream os = new FileOutputStream(f);

e.writeTo(os);
while (e.isStreaming()) {
   e.writeTo(os);
}

Where e is my HttpEntity and f is my file. I only get the first 8KB of any file, I guess due to buffering somewhere. Any idea how I get the rest?

A: 

Solved it.

I needed to force the response object to use a BufferedHttpEntity:

HttpEntity entity = rsp.getEntity();
BufferedHttpEntity buf = new BufferedHttpEntity(entity);
Adrian Mouat