[4.1] 1215933 Disable speculative Range handling on streaming transactions where we don't yet know the length.
Poul-Henning Kamp
phk at FreeBSD.org
Fri Sep 4 15:54:55 CEST 2015
commit 121593312daabbef4e290a590b364a099980a8b7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Aug 25 15:42:26 2015 +0000
Disable speculative Range handling on streaming transactions where
we don't yet know the length.
I attempted to add a way to determine if the object was big enough
*yet* to satisfy the Range, but that was non-viable.
Fixes: #1777
diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c
index 729533e..9b2580e 100644
--- a/bin/varnishd/cache/cache_range.c
+++ b/bin/varnishd/cache/cache_range.c
@@ -137,7 +137,7 @@ vrg_dorange(struct req *req, const char *r)
high = req->resp_len - 1;
} else if (req->resp_len >= 0 && (high >= req->resp_len || !has_high))
high = req->resp_len - 1;
- else if (!has_high)
+ else if (!has_high || req->resp_len < 0)
return (NULL); // Allow 200 response
/*
* else (bo != NULL) {
diff --git a/bin/varnishtest/tests.disabled/e00029.vtc b/bin/varnishtest/tests.disabled/e00029.vtc
new file mode 100644
index 0000000..ea3dd70
--- /dev/null
+++ b/bin/varnishtest/tests.disabled/e00029.vtc
@@ -0,0 +1,42 @@
+varnishtest "fun esi includes and ranges"
+
+server s1 {
+ rxreq
+ expect req.url == "/1"
+ txresp -body {<html><esi:include src="/bar"/></html>}
+
+ rxreq
+ expect req.url == /bar
+ txresp -body {<html><esi:include src="/foo"/></html>}
+
+ rxreq
+ expect req.url == /foo
+ txresp -body "ABCD"
+
+ rxreq
+ expect req.url == "/2"
+ txresp -gzipbody {<html><esi:include src="/bar"/></html>}
+
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ if (req.url == "/bar") {
+ set req.http.Range = "bytes=7-8";
+ }
+ }
+ sub vcl_backend_response {
+ set beresp.do_esi = true;
+ }
+} -start
+
+client c1 {
+ txreq -url /1 -hdr "Accept-encoding: gzip"
+ rxresp
+ expect resp.body == "<html>BC</html>"
+ delay .1
+ txreq -url /2 -hdr "Accept-encoding: gzip"
+ rxresp
+ gunzip
+ expect resp.body == "<html>BC</html>"
+} -run
diff --git a/bin/varnishtest/tests.disabled/r01506.vtc b/bin/varnishtest/tests.disabled/r01506.vtc
new file mode 100644
index 0000000..f2bb5b2
--- /dev/null
+++ b/bin/varnishtest/tests.disabled/r01506.vtc
@@ -0,0 +1,72 @@
+varnishtest "range requests on streamed response"
+
+server s1 -repeat 4 {
+ rxreq
+ txresp -nolen \
+ -hdr "Transfer-Encoding: chunked" \
+ -hdr "Connection: close"
+ send "11\r\n0_23456789abcdef\n"
+ send "11\r\n1_23456789abcdef\n"
+ send "11\r\n2_23456789abcdef\n"
+ send "11\r\n3_23456789abcdef\n"
+ sema r1 sync 2
+ send "11\r\n4_23456789abcdef\n"
+ send "11\r\n5_23456789abcdef\n"
+ send "11\r\n6_23456789abcdef\n"
+ send "11\r\n7_23456789abcdef\n"
+ chunkedlen 0
+
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+varnish v1 -cliok "param.set debug +syncvsl"
+
+logexpect l1 -v v1 -g session {
+ expect 0 1000 Begin sess
+ expect * = SessClose RANGE_SHORT
+} -start
+
+client c1 {
+ txreq -url /1 -hdr "Range: bytes=17-101"
+ rxresphdrs
+ expect resp.status == 206
+ expect resp.http.content-length == 85
+ sema r1 sync 2
+ rxrespbody
+ expect resp.bodylen == 85
+ delay .1
+
+ # We cannot do tail-ranges when streaming
+ txreq -url /2 -hdr "Range: bytes=-10"
+ rxresphdrs
+ expect resp.status == 200
+ expect resp.http.Transfer-Encoding == chunked
+ sema r1 sync 2
+ rxrespbody
+ expect resp.bodylen == 136
+ delay .1
+
+ # We cannot do open-ranges when streaming
+ txreq -url /3 -hdr "Range: bytes=17-"
+ rxresphdrs
+ expect resp.status == 200
+ expect resp.http.Transfer-Encoding == chunked
+ sema r1 sync 2
+ rxrespbody
+ expect resp.bodylen == 136
+ delay .1
+
+ # Invalid range
+ txreq -url /4 -hdr "Range: bytes=102-200"
+ rxresphdrs
+ expect resp.status == 206
+ expect resp.http.content-length == 99
+ sema r1 sync 2
+ recv 34
+ delay .3
+ expect_close
+} -run
+
+varnish v1 -expect sc_range_short == 1
+logexpect l1 -wait
diff --git a/bin/varnishtest/tests.disabled/r01732.vtc b/bin/varnishtest/tests.disabled/r01732.vtc
new file mode 100644
index 0000000..f738dec
--- /dev/null
+++ b/bin/varnishtest/tests.disabled/r01732.vtc
@@ -0,0 +1,38 @@
+varnishtest "range related panic"
+
+server s1 {
+ rxreq
+ txresp -nolen -hdr "Transfer-Encoding: chunked"
+ chunkedlen 10
+ chunkedlen 10
+ sema r1 sync 2
+ chunkedlen 10
+ chunkedlen 10
+ chunkedlen 10
+ chunkedlen 0
+ delay .1
+ sema r2 sync 2
+} -start
+
+varnish v1 -vcl+backend {
+} -start
+
+client c1 {
+ txreq -hdr "Range: bytes=0-100"
+ rxresphdrs
+ expect resp.status == 206
+ expect resp.http.Content-Range == "bytes 0-100/*"
+} -run
+
+delay .1
+sema r1 sync 2
+sema r2 sync 2
+delay .4
+
+client c1 {
+ txreq -hdr "Range: bytes=0-100"
+ rxresp
+ expect resp.status == 206
+ expect resp.http.Content-Range == "bytes 0-49/50"
+} -run
+
diff --git a/bin/varnishtest/tests/c00034.vtc b/bin/varnishtest/tests/c00034.vtc
index b1698cd..2b440c9 100644
--- a/bin/varnishtest/tests/c00034.vtc
+++ b/bin/varnishtest/tests/c00034.vtc
@@ -176,7 +176,7 @@ client c1 {
-hdr "Range: bytes=2-5" \
-hdr "Accept-encoding: gzip"
rxresp
- expect resp.status == 206
- expect resp.http.Content-Range == "bytes 2-5/*"
- expect resp.http.Content-Length == 4
+ expect resp.status == 200
+ gunzip
+ expect resp.bodylen == 100
} -run
diff --git a/bin/varnishtest/tests/e00029.vtc b/bin/varnishtest/tests/e00029.vtc
deleted file mode 100644
index ea3dd70..0000000
--- a/bin/varnishtest/tests/e00029.vtc
+++ /dev/null
@@ -1,42 +0,0 @@
-varnishtest "fun esi includes and ranges"
-
-server s1 {
- rxreq
- expect req.url == "/1"
- txresp -body {<html><esi:include src="/bar"/></html>}
-
- rxreq
- expect req.url == /bar
- txresp -body {<html><esi:include src="/foo"/></html>}
-
- rxreq
- expect req.url == /foo
- txresp -body "ABCD"
-
- rxreq
- expect req.url == "/2"
- txresp -gzipbody {<html><esi:include src="/bar"/></html>}
-
-} -start
-
-varnish v1 -vcl+backend {
- sub vcl_recv {
- if (req.url == "/bar") {
- set req.http.Range = "bytes=7-8";
- }
- }
- sub vcl_backend_response {
- set beresp.do_esi = true;
- }
-} -start
-
-client c1 {
- txreq -url /1 -hdr "Accept-encoding: gzip"
- rxresp
- expect resp.body == "<html>BC</html>"
- delay .1
- txreq -url /2 -hdr "Accept-encoding: gzip"
- rxresp
- gunzip
- expect resp.body == "<html>BC</html>"
-} -run
diff --git a/bin/varnishtest/tests/r01506.vtc b/bin/varnishtest/tests/r01506.vtc
deleted file mode 100644
index f2bb5b2..0000000
--- a/bin/varnishtest/tests/r01506.vtc
+++ /dev/null
@@ -1,72 +0,0 @@
-varnishtest "range requests on streamed response"
-
-server s1 -repeat 4 {
- rxreq
- txresp -nolen \
- -hdr "Transfer-Encoding: chunked" \
- -hdr "Connection: close"
- send "11\r\n0_23456789abcdef\n"
- send "11\r\n1_23456789abcdef\n"
- send "11\r\n2_23456789abcdef\n"
- send "11\r\n3_23456789abcdef\n"
- sema r1 sync 2
- send "11\r\n4_23456789abcdef\n"
- send "11\r\n5_23456789abcdef\n"
- send "11\r\n6_23456789abcdef\n"
- send "11\r\n7_23456789abcdef\n"
- chunkedlen 0
-
-} -start
-
-varnish v1 -vcl+backend {} -start
-
-varnish v1 -cliok "param.set debug +syncvsl"
-
-logexpect l1 -v v1 -g session {
- expect 0 1000 Begin sess
- expect * = SessClose RANGE_SHORT
-} -start
-
-client c1 {
- txreq -url /1 -hdr "Range: bytes=17-101"
- rxresphdrs
- expect resp.status == 206
- expect resp.http.content-length == 85
- sema r1 sync 2
- rxrespbody
- expect resp.bodylen == 85
- delay .1
-
- # We cannot do tail-ranges when streaming
- txreq -url /2 -hdr "Range: bytes=-10"
- rxresphdrs
- expect resp.status == 200
- expect resp.http.Transfer-Encoding == chunked
- sema r1 sync 2
- rxrespbody
- expect resp.bodylen == 136
- delay .1
-
- # We cannot do open-ranges when streaming
- txreq -url /3 -hdr "Range: bytes=17-"
- rxresphdrs
- expect resp.status == 200
- expect resp.http.Transfer-Encoding == chunked
- sema r1 sync 2
- rxrespbody
- expect resp.bodylen == 136
- delay .1
-
- # Invalid range
- txreq -url /4 -hdr "Range: bytes=102-200"
- rxresphdrs
- expect resp.status == 206
- expect resp.http.content-length == 99
- sema r1 sync 2
- recv 34
- delay .3
- expect_close
-} -run
-
-varnish v1 -expect sc_range_short == 1
-logexpect l1 -wait
diff --git a/bin/varnishtest/tests/r01732.vtc b/bin/varnishtest/tests/r01732.vtc
deleted file mode 100644
index f738dec..0000000
--- a/bin/varnishtest/tests/r01732.vtc
+++ /dev/null
@@ -1,38 +0,0 @@
-varnishtest "range related panic"
-
-server s1 {
- rxreq
- txresp -nolen -hdr "Transfer-Encoding: chunked"
- chunkedlen 10
- chunkedlen 10
- sema r1 sync 2
- chunkedlen 10
- chunkedlen 10
- chunkedlen 10
- chunkedlen 0
- delay .1
- sema r2 sync 2
-} -start
-
-varnish v1 -vcl+backend {
-} -start
-
-client c1 {
- txreq -hdr "Range: bytes=0-100"
- rxresphdrs
- expect resp.status == 206
- expect resp.http.Content-Range == "bytes 0-100/*"
-} -run
-
-delay .1
-sema r1 sync 2
-sema r2 sync 2
-delay .4
-
-client c1 {
- txreq -hdr "Range: bytes=0-100"
- rxresp
- expect resp.status == 206
- expect resp.http.Content-Range == "bytes 0-49/50"
-} -run
-
diff --git a/bin/varnishtest/tests/r01777.vtc b/bin/varnishtest/tests/r01777.vtc
new file mode 100644
index 0000000..6808023
--- /dev/null
+++ b/bin/varnishtest/tests/r01777.vtc
@@ -0,0 +1,18 @@
+varnishtest "range asked longer than object"
+
+server s1 {
+ rxreq
+ txresp -nolen -hdr "Transfer-Encoding: chunked"
+ delay .5
+ chunkedlen 64
+ chunkedlen 64
+ chunkedlen 0
+} -start
+
+varnish v1 -vcl+backend { } -start
+
+client c1 {
+ txreq -hdr "Range: bytes=0-129"
+ rxresp
+ expect resp.status == 200
+} -run
More information about the varnish-commit
mailing list