aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-10-27 12:05:36 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-10-27 12:05:36 +0000
commit9d152a77fd4b2c64db4631119103bbc13385945f (patch)
tree136ebafa21988ae0087c099d2928adc552deb0f4 /src/main.c
parent33dc28b90514657eb13a4c029a9cc51d5041a8a4 (diff)
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.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 818b5baab..cd42b0d06 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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 */