HTTPCLIENT-1341] DeflateDecompressingEntity does not call Inflater#end
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1469235 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
456461b1c6
commit
68243b227f
|
@ -1,6 +1,9 @@
|
||||||
Changes since release 4.3 BETA1
|
Changes since release 4.3 BETA1
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* [HTTPCLIENT-1341] DeflateDecompressingEntity does not call Inflater#end.
|
||||||
|
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
||||||
|
|
||||||
* [HTTPCLIENT-1299] (regression) cache incorrectly disposes of the underlying cache resource
|
* [HTTPCLIENT-1299] (regression) cache incorrectly disposes of the underlying cache resource
|
||||||
when storing variant entry.
|
when storing variant entry.
|
||||||
Contributed by James Leigh <james at 3roundstones.com>
|
Contributed by James Leigh <james at 3roundstones.com>
|
||||||
|
|
|
@ -142,13 +142,15 @@ public class DeflateDecompressingEntity extends DecompressingEntity {
|
||||||
* and return an unused InputStream now.
|
* and return an unused InputStream now.
|
||||||
*/
|
*/
|
||||||
pushback.unread(peeked, 0, headerLength);
|
pushback.unread(peeked, 0, headerLength);
|
||||||
return new InflaterInputStream(pushback);
|
return new DeflateStream(pushback, new Inflater());
|
||||||
} catch (final DataFormatException e) {
|
} catch (final DataFormatException e) {
|
||||||
|
|
||||||
/* Presume that it's an RFC1951 deflate stream rather than RFC1950 zlib stream and try
|
/* Presume that it's an RFC1951 deflate stream rather than RFC1950 zlib stream and try
|
||||||
* again. */
|
* again. */
|
||||||
pushback.unread(peeked, 0, headerLength);
|
pushback.unread(peeked, 0, headerLength);
|
||||||
return new InflaterInputStream(pushback, new Inflater(true));
|
return new DeflateStream(pushback, new Inflater(true));
|
||||||
|
} finally {
|
||||||
|
inf.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,4 +174,24 @@ public class DeflateDecompressingEntity extends DecompressingEntity {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class DeflateStream extends InflaterInputStream {
|
||||||
|
|
||||||
|
private boolean closed = false;
|
||||||
|
|
||||||
|
public DeflateStream(final InputStream in, final Inflater inflater) {
|
||||||
|
super(in, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
if (closed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
closed = true;
|
||||||
|
inf.end();
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue