Commit 947067c4 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r4866: Make bytes=-100 work

I have no idea how I overlooked that a "bytes=-100" range was from the
end of the object, but I did.

Fixes #704.

Reported by:    Luc Saillard



git-svn-id: http://www.varnish-cache.org/svn/branches/2.1@5025 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0e78e25d
...@@ -131,7 +131,7 @@ res_do_conds(struct sess *sp) ...@@ -131,7 +131,7 @@ res_do_conds(struct sess *sp)
static void static void
res_dorange(struct sess *sp, const char *r, unsigned *plow, unsigned *phigh) res_dorange(struct sess *sp, const char *r, unsigned *plow, unsigned *phigh)
{ {
unsigned low, high; unsigned low, high, has_low;
(void)sp; (void)sp;
if (strncmp(r, "bytes=", 6)) if (strncmp(r, "bytes=", 6))
...@@ -139,10 +139,11 @@ res_dorange(struct sess *sp, const char *r, unsigned *plow, unsigned *phigh) ...@@ -139,10 +139,11 @@ res_dorange(struct sess *sp, const char *r, unsigned *plow, unsigned *phigh)
r += 6; r += 6;
/* The low end of range */ /* The low end of range */
low = 0; has_low = low = 0;
if (!vct_isdigit(*r) && *r != '-') if (!vct_isdigit(*r) && *r != '-')
return; return;
while (vct_isdigit(*r)) { while (vct_isdigit(*r)) {
has_low = 1;
low *= 10; low *= 10;
low += *r - '0'; low += *r - '0';
r++; r++;
...@@ -163,6 +164,10 @@ res_dorange(struct sess *sp, const char *r, unsigned *plow, unsigned *phigh) ...@@ -163,6 +164,10 @@ res_dorange(struct sess *sp, const char *r, unsigned *plow, unsigned *phigh)
high += *r - '0'; high += *r - '0';
r++; r++;
} }
if (!has_low) {
low = sp->obj->len - high;
high = sp->obj->len - 1;
}
} else } else
high = sp->obj->len - 1; high = sp->obj->len - 1;
if (*r != '\0') if (*r != '\0')
......
...@@ -59,7 +59,7 @@ client c1 { ...@@ -59,7 +59,7 @@ client c1 {
txreq -hdr "Range: bytes=-9" txreq -hdr "Range: bytes=-9"
rxresp rxresp
expect resp.status == 206 expect resp.status == 206
expect resp.bodylen == 10 expect resp.bodylen == 9
txreq -hdr "Range: bytes=-" txreq -hdr "Range: bytes=-"
rxresp rxresp
......
# $Id$
test "Range bug"
server s1 {
rxreq
txresp -bodylen 100
} -start
varnish v1 -vcl+backend {
} -start
varnish v1 -cliok "param.set http_range_support on"
client c1 {
txreq -hdr "Range: bytes=-20"
rxresp
expect resp.status == 206
expect resp.bodylen == 20
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment