From 170a469533b6e78a5694f62d3a5f42885a43310b Mon Sep 17 00:00:00 2001
From: Darshit Shah <darnir@gmail.com>
Date: Sun, 9 Nov 2014 14:33:13 +0530
Subject: [PATCH] Honour Keep-Alive when range not satisfiable

---
 src/ChangeLog | 5 +++++
 src/http.c    | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 7cc18131..0c41b1ed 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-09  Darshit Shah  <darnir@gmail.com>
+
+	* http.c (gethttps): Honour keep-alive when server responds with a 416 Range
+	not Satisfiable
+
 2014-11-09  Darshit Shah  <darnir@gmail.com>
 
 	* http.c (gethttp): Remove redundant condition evaluation
diff --git a/src/http.c b/src/http.c
index c112824f..584f4a85 100644
--- a/src/http.c
+++ b/src/http.c
@@ -2776,7 +2776,10 @@ read_header:
       /* Mark as successfully retrieved. */
       *dt |= RETROKF;
       xfree_null (type);
-      CLOSE_INVALIDATE (sock);        /* would be CLOSE_FINISH, but there
+      if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE)
+        CLOSE_FINISH (sock);
+      else
+        CLOSE_INVALIDATE (sock);        /* would be CLOSE_FINISH, but there
                                    might be more bytes in the body. */
       xfree (head);
       return RETRUNNEEDED;