Defeat connection reuse to really cancel.
Jeff Sharkey [Fri, 7 Nov 2014 22:41:24 +0000 (14:41 -0800)]
Otherwise servers may continue streaming large downloads into the
kept-alive socket.  This changes to always close the socket, sending
a clear signal to server.

Bug: 16153076
Change-Id: I3e7fefce4f82b5f80abaab58874cc4c4374d2bfb

src/com/android/providers/downloads/DownloadThread.java

index 51e71b2..c0f5a5e 100644 (file)
@@ -792,6 +792,10 @@ public class DownloadThread implements Runnable {
         // easily resume partial downloads.
         conn.setRequestProperty("Accept-Encoding", "identity");
 
+        // Defeat connection reuse, since otherwise servers may continue
+        // streaming large downloads after cancelled.
+        conn.setRequestProperty("Connection", "close");
+
         if (resuming) {
             if (mInfoDelta.mETag != null) {
                 conn.addRequestProperty("If-Match", mInfoDelta.mETag);