Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
7da66c9b
Commit
7da66c9b
authored
Nov 29, 2022
by
Gil Pedersen
Committed by
Poul-Henning Kamp
Jan 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve streaming range responses
This is an enhanced fix for #1777
parent
ebc18974
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
28 deletions
+23
-28
cache_range.c
bin/varnishd/cache/cache_range.c
+4
-4
c00034.vtc
bin/varnishtest/tests/c00034.vtc
+3
-5
e00015.vtc
bin/varnishtest/tests/e00015.vtc
+5
-9
g00005.vtc
bin/varnishtest/tests/g00005.vtc
+4
-3
r01506.vtc
bin/varnishtest/tests/r01506.vtc
+3
-6
r01732.vtc
bin/varnishtest/tests/r01732.vtc
+0
-0
r01777.vtc
bin/varnishtest/tests/r01777.vtc
+4
-1
No files found.
bin/varnishd/cache/cache_range.c
View file @
7da66c9b
...
...
@@ -124,7 +124,7 @@ vrg_dorange(struct req *req, void **priv)
high
=
req
->
resp_len
-
1
;
}
else
if
(
req
->
resp_len
>=
0
&&
(
high
>=
req
->
resp_len
||
high
<
0
))
high
=
req
->
resp_len
-
1
;
else
if
(
high
<
0
||
req
->
resp_len
<
0
)
else
if
(
high
<
0
)
return
(
NULL
);
// Allow 200 response
/*
* else (bo != NULL) {
...
...
@@ -136,13 +136,13 @@ vrg_dorange(struct req *req, void **priv)
if
(
req
->
resp_len
>=
0
&&
low
>=
req
->
resp_len
)
return
(
"low range beyond object"
);
if
(
req
->
resp_len
>=
0
)
if
(
req
->
resp_len
>=
0
)
{
http_PrintfHeader
(
req
->
resp
,
"Content-Range: bytes %jd-%jd/%jd"
,
(
intmax_t
)
low
,
(
intmax_t
)
high
,
(
intmax_t
)
req
->
resp_len
);
else
req
->
resp_len
=
(
intmax_t
)(
1
+
high
-
low
);
}
else
http_PrintfHeader
(
req
->
resp
,
"Content-Range: bytes %jd-%jd/*"
,
(
intmax_t
)
low
,
(
intmax_t
)
high
);
req
->
resp_len
=
(
intmax_t
)(
1
+
high
-
low
);
vrg_priv
=
WS_Alloc
(
req
->
ws
,
sizeof
*
vrg_priv
);
if
(
vrg_priv
==
NULL
)
...
...
bin/varnishtest/tests/c00034.vtc
View file @
7da66c9b
...
...
@@ -178,12 +178,10 @@ client c5 {
-hdr "Range: bytes=2-5" \
-hdr "Accept-encoding: gzip"
rxresp
expect resp.status == 20
0
expect resp.http.Content-Range ==
<undef>
expect resp.status == 20
6
expect resp.http.Content-Range ==
"bytes 2-5/*"
expect resp.http.Content-Length == <undef>
expect resp.http.Content-Encoding == gzip
gunzip
expect resp.bodylen == 100
expect resp.bodylen == 4
} -run
# Test partial range with http2
...
...
bin/varnishtest/tests/e00015.vtc
View file @
7da66c9b
...
...
@@ -87,8 +87,6 @@ varnish v1 -syntax 4.1 -vcl+backend {
}
}
# Note on Range requests: The range VDP is active, but as it cannot
# reliably determine the size of the response, it falls back to a 200
client c1 {
txreq -url /top2
rxresp
...
...
@@ -106,11 +104,10 @@ client c1 {
expect resp.http.filter0 == "esi"
expect resp.http.filters == "esi"
# see Note on Range above
txreq -url "/esi" -hdr "Range: bytes=1-2"
rxresp
expect resp.bodylen ==
76
expect resp.status == 20
0
expect resp.bodylen ==
2
expect resp.status == 20
6
expect resp.http.was == true
expect resp.http.filters == "esi range"
...
...
@@ -121,11 +118,10 @@ client c1 {
expect resp.http.was == true
expect resp.http.filters == "esi gunzip"
# see Note on Range above
txreq -url "/recurse" -hdr "Range: bytes=1-2"
rxresp
expect resp.bodylen ==
120
expect resp.status == 20
0
expect resp.bodylen ==
2
expect resp.status == 20
6
expect resp.http.was == true
expect resp.http.filters == "esi gunzip range"
...
...
@@ -136,4 +132,4 @@ client c1 {
} -run
varnish v1 -expect esi_errors == 0
varnish v1 -expect MAIN.s_resp_bodybytes ==
865
varnish v1 -expect MAIN.s_resp_bodybytes ==
673
bin/varnishtest/tests/g00005.vtc
View file @
7da66c9b
...
...
@@ -25,12 +25,13 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend {
} -start
client c1 {
#
no range support with streaming cache miss and gunzip
#
cache miss
txreq -hdr "Range: bytes=3-5"
rxresp
expect resp.status == 20
0
expect resp.bodylen == "
10
"
expect resp.status == 20
6
expect resp.bodylen == "
3
"
expect resp.http.content-encoding == <undef>
expect resp.body == "BAR"
} -run
varnish v1 -vsl_catchup
...
...
bin/varnishtest/tests
.disabled
/r01506.vtc
→
bin/varnishtest/tests/r01506.vtc
View file @
7da66c9b
...
...
@@ -33,7 +33,6 @@ client c1 {
txreq -url /1 -hdr "Range: bytes=17-101"
rxresphdrs
expect resp.status == 206
expect resp.http.content-length == 85
barrier b1 sync
rxrespbody
expect resp.bodylen == 85
...
...
@@ -59,15 +58,13 @@ client c1 {
expect resp.bodylen == 136
delay .1
#
Invalid
range
#
Handles out of bounds
range
txreq -url /4 -hdr "Range: bytes=102-200"
rxresphdrs
expect resp.status == 206
expect resp.http.content-length == 99
barrier b1 sync
recv 34
delay .3
expect_close
rxrespbody
expect resp.bodylen == 34
} -run
varnish v1 -expect sc_range_short == 1
...
...
bin/varnishtest/tests
.disabled
/r01732.vtc
→
bin/varnishtest/tests/r01732.vtc
View file @
7da66c9b
File moved
bin/varnishtest/tests/r01777.vtc
View file @
7da66c9b
...
...
@@ -14,5 +14,8 @@ varnish v1 -vcl+backend { } -start
client c1 {
txreq -hdr "Range: bytes=0-129"
rxresp
expect resp.status == 200
expect resp.status == 206
expect resp.http.Content-Range == "bytes 0-129/*"
expect resp.http.Content-Length == <undef>
expect resp.bodylen == 128
} -run
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment