Jaz Fresh pointed out that if you used "-r [number]" as was wrongly described
authorDaniel Stenberg <daniel@haxx.se>
Thu, 27 Oct 2005 12:05:36 +0000 (12:05 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 27 Oct 2005 12:05:36 +0000 (12:05 +0000)
in the man page, curl would send an invalid HTTP Range: header. The correct
way would be to use "-r [number]-" or even "-r -[number]". Starting now,
curl will warn if this is discovered, and automatically append a dash to the
range before passing it to libcurl.

CHANGES
RELEASE-NOTES
docs/curl.1
src/main.c

diff --git a/CHANGES b/CHANGES
index a998afb..da9f357 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,13 @@
 
 
 
+Daniel (27 October 2005)
+- Jaz Fresh pointed out that if you used "-r [number]" as was wrongly described
+  in the man page, curl would send an invalid HTTP Range: header. The correct
+  way would be to use "-r [number]-" or even "-r -[number]". Starting now,
+  curl will warn if this is discovered, and automatically append a dash to the
+  range before passing it to libcurl.
+
 Daniel (25 October 2005)
 - Amol Pattekar reported a bug with great detail and a fine example in bug
   #1326306 (http://curl.haxx.se/bug/view.cgi?id=1326306). When using the multi
index 93426d6..e848117 100644 (file)
@@ -15,6 +15,7 @@ This release includes the following changes:
 
 This release includes the following bugfixes:
 
+ o -r [num] would produce an invalid HTTP Range: header
  o multi interface with multi IP hosts could leak socket descriptors
  o the GnuTLS code didn't handle rehandshakes
  o re-use of a dead FTP connection
@@ -32,6 +33,7 @@ Other curl-related news since the previous public release:
 This release would not have looked like this without help, code, reports and
 advice from friends like these:
 
- Dave Dribin, Bradford Bruce, Temprimus
+ Dave Dribin, Bradford Bruce, Temprimus, Ofer, Dima Barsky, Amol Pattekar, Jaz
+ Fresh
 
         Thanks! (and sorry if I forgot to mention someone)
index 69d890a..8a422b9 100644 (file)
@@ -770,7 +770,7 @@ specifies the second 500 bytes
 .B -500
 specifies the last 500 bytes
 .TP
-.B 9500
+.B 9500-
 specifies the bytes from offset 9500 and forward
 .TP
 .B 0-0,-1
index 818b5ba..cd42b0d 100644 (file)
@@ -2097,8 +2097,24 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
         return err;
       break;
     case 'r':
-      /* byte range requested */
-      GetStr(&config->range, nextarg);
+      /* Specifying a range WITHOUT A DASH will create an illegal HTTP range
+         (and won't actually be range by definition). The man page previously
+         claimed that to be a good way, why this code is added to work-around
+         it. */
+      if(!strchr(nextarg, '-')) {
+        char buffer[32];
+        curl_off_t off;
+        warnf(config,
+              "A specfied range MUST include at least one dash (-). "
+              "Appending one for you!\n");
+        off = curlx_strtoofft(nextarg, NULL, 10);
+        snprintf(buffer, sizeof(buffer), CURL_FORMAT_OFF_T "-", off);
+        GetStr(&config->range, buffer);
+      }
+      else
+        /* byte range requested */
+        GetStr(&config->range, nextarg);
+
       break;
     case 'R':
       /* use remote file's time */