r4866 - in trunk/varnish-cache/bin: varnishd varnishtest/tests
phk at varnish-cache.org
phk at varnish-cache.org
Mon May 31 10:50:36 CEST 2010
Author: phk
Date: 2010-05-31 10:50:35 +0200 (Mon, 31 May 2010)
New Revision: 4866
Added:
trunk/varnish-cache/bin/varnishtest/tests/r00704.vtc
Modified:
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishtest/tests/c00034.vtc
Log:
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
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2010-05-31 08:00:23 UTC (rev 4865)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2010-05-31 08:50:35 UTC (rev 4866)
@@ -131,7 +131,7 @@
static void
res_dorange(struct sess *sp, const char *r, unsigned *plow, unsigned *phigh)
{
- unsigned low, high;
+ unsigned low, high, has_low;
(void)sp;
if (strncmp(r, "bytes=", 6))
@@ -139,10 +139,11 @@
r += 6;
/* The low end of range */
- low = 0;
+ has_low = low = 0;
if (!vct_isdigit(*r) && *r != '-')
return;
while (vct_isdigit(*r)) {
+ has_low = 1;
low *= 10;
low += *r - '0';
r++;
@@ -163,6 +164,10 @@
high += *r - '0';
r++;
}
+ if (!has_low) {
+ low = sp->obj->len - high;
+ high = sp->obj->len - 1;
+ }
} else
high = sp->obj->len - 1;
if (*r != '\0')
Modified: trunk/varnish-cache/bin/varnishtest/tests/c00034.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/c00034.vtc 2010-05-31 08:00:23 UTC (rev 4865)
+++ trunk/varnish-cache/bin/varnishtest/tests/c00034.vtc 2010-05-31 08:50:35 UTC (rev 4866)
@@ -59,7 +59,7 @@
txreq -hdr "Range: bytes=-9"
rxresp
expect resp.status == 206
- expect resp.bodylen == 10
+ expect resp.bodylen == 9
txreq -hdr "Range: bytes=-"
rxresp
Added: trunk/varnish-cache/bin/varnishtest/tests/r00704.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00704.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00704.vtc 2010-05-31 08:50:35 UTC (rev 4866)
@@ -0,0 +1,22 @@
+# $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
+
More information about the varnish-commit
mailing list