HTTPCLIENT-1078: Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity) do not close content stream in #writeTo() method

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1091140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2011-04-11 17:38:37 +00:00
parent 584bc97d49
commit 281d9d5f4d
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,9 @@
Changes since 4.1.1 Changes since 4.1.1
* [HTTPCLIENT-1078] Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity)
do not close content stream in #writeTo() method.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-1075] Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity) * [HTTPCLIENT-1075] Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity)
do not correctly handle content streaming. do not correctly handle content streaming.
Contributed by James Abley <james.abley at gmail.com> Contributed by James Abley <james.abley at gmail.com>

View File

@ -85,15 +85,17 @@ abstract class DecompressingEntity extends HttpEntityWrapper {
if (outstream == null) { if (outstream == null) {
throw new IllegalArgumentException("Output stream may not be null"); throw new IllegalArgumentException("Output stream may not be null");
} }
InputStream instream = getContent(); InputStream instream = getContent();
try {
byte[] buffer = new byte[BUFFER_SIZE];
byte[] buffer = new byte[BUFFER_SIZE]; int l;
int l; while ((l = instream.read(buffer)) != -1) {
outstream.write(buffer, 0, l);
while ((l = instream.read(buffer)) != -1) { }
outstream.write(buffer, 0, l); } finally {
instream.close();
} }
} }