From d8c61d459e528ead954482ac797861bce95dd895 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Fri, 1 Dec 2006 07:49:22 +0000
Subject: [PATCH] Toon Verwaest reported that there are servers that send the
 Content-Range: header in a third, not suppported by libcurl, format and we
 agreed that we could make the parser more forgiving to accept all the three
 found variations.

---
 CHANGES        |  6 ++++++
 RELEASE-NOTES  |  3 ++-
 lib/transfer.c | 11 ++++++-----
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/CHANGES b/CHANGES
index c19e62b96d..d98d43beba 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,12 @@
 
                                   Changelog
 
+Daniel (1 December 2006)
+- Toon Verwaest reported that there are servers that send the Content-Range:
+  header in a third, not suppported by libcurl, format and we agreed that we
+  could make the parser more forgiving to accept all the three found
+  variations.
+
 Daniel (25 November 2006)
 - Venkat Akella found out that libcurl did not like HTTP responses that simply
   responded with a single status line and no headers nor body. Starting now, a
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 5bccf5cde0..d71371b4d5 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -25,6 +25,7 @@ This release includes the following bugfixes:
  o stack overwrite on 64bit Windows in the chunked decoding department
  o HTTP responses on persistent connections without Content-Length nor chunked
    encoding are now considered to be without response body
+ o Content-Range: header parsing improved
 
 Other curl-related news:
 
@@ -40,6 +41,6 @@ This release would not have looked like this without help, code, reports and
 advice from friends like these:
 
  James Housley, Olaf Stueben, Yang Tse, Gisle Vanem, Bradford Bruce,
- Ciprian Badescu, Dmitriy Sergeyev, Nir Soffer, Venkat Akella
+ Ciprian Badescu, Dmitriy Sergeyev, Nir Soffer, Venkat Akella, Toon Verwaest
 
         Thanks! (and sorry if I forgot to mention someone)
diff --git a/lib/transfer.c b/lib/transfer.c
index e3d85aee04..a40c103e18 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -904,19 +904,20 @@ CURLcode Curl_readwrite(struct connectdata *conn,
                        || checkprefix("x-compress", start))
                 k->content_encoding = COMPRESS;
             }
-            else if (Curl_compareheader(k->p, "Content-Range:", "bytes")) {
+            else if (checkprefix("Content-Range:", k->p)) {
               /* Content-Range: bytes [num]-
                  Content-Range: bytes: [num]-
+                 Content-Range: [num]-
 
                  The second format was added since Sun's webserver
                  JavaWebServer/1.1.1 obviously sends the header this way!
+                 The third added since some servers use that!
               */
 
-              char *ptr = Curl_strcasestr(k->p, "bytes");
-              ptr+=5;
+              char *ptr = k->p + 14;
 
-              if(*ptr == ':')
-                /* stupid colon skip */
+              /* Move forward until first digit */
+              while(*ptr && !ISDIGIT(*ptr))
                 ptr++;
 
               k->offset = curlx_strtoofft(ptr, NULL, 10);
-- 
GitLab