summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java')
-rw-r--r--luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java b/luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java
index a59df55..260a9ad 100644
--- a/luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java
+++ b/luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java
@@ -36,6 +36,7 @@ import java.security.Permission;
import java.util.List;
import java.util.Map;
import libcore.io.Base64;
+import libcore.io.IoUtils;
/**
* This implementation uses HttpEngine to send requests and receive responses.
@@ -87,6 +88,14 @@ class HttpURLConnectionImpl extends HttpURLConnection {
@Override public final void disconnect() {
// Calling disconnect() before a connection exists should have no effect.
if (httpEngine != null) {
+ // We close the response body here instead of in
+ // HttpEngine.release because that is called when input
+ // has been completely read from the underlying socket.
+ // However the response body can be a GZIPInputStream that
+ // still has unread data.
+ if (httpEngine.hasResponse()) {
+ IoUtils.closeQuietly(httpEngine.getResponseBody());
+ }
httpEngine.release(false);
}
}