Commit bb098e3f authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

range: Check content-range unsatisfied-range

And while at it add coverage for `content-range: bytes */*` for good
measure.

Fixes #3683
parent f6ee60cb
......@@ -898,8 +898,6 @@ http_GetContentRange(const struct http *hp, ssize_t *lo, ssize_t *hi)
if (*lo > *hi)
return (-2);
assert(cl >= -1);
if (cl == -1)
return (-1);
if (*lo >= cl || *hi >= cl)
return (-2);
AN(cl);
......
......@@ -287,7 +287,7 @@ VRG_CheckBo(struct busyobj *bo)
return (-1);
}
if (crlo < 0 || crhi < 0) {
if (crlo < 0 && crhi < 0 && crlen < 0) {
AZ(http_GetHdr(bo->beresp, H_Content_Range, NULL));
return (0);
}
......@@ -297,6 +297,13 @@ VRG_CheckBo(struct busyobj *bo)
return (-1);
}
if (crlo < 0) { // Content-Range: bytes */123
assert(crhi < 0);
assert(crlen > 0);
crlo = 0;
crhi = crlen - 1;
}
#define RANGE_CHECK(val, op, crval, what) \
do { \
if (val >= 0 && !(val op crval)) { \
......
......@@ -246,9 +246,18 @@ server s1 {
txresp -status 206 -hdr "content-range: bytes 10-19/100" -bodylen 40
rxreq
expect req.url == "/4"
expect req.url == "/?unexpected=content-range"
expect req.http.range == <undef>
txresp -hdr "content-range: bytes 0-49/100" -bodylen 40
rxreq
expect req.url == "/?unexpected=unsatisfied-range"
expect req.http.range == <undef>
txresp -hdr "content-range: bytes */100" -bodylen 100
rxreq
expect req.http.range == "bytes=0-0"
txresp -hdr "content-range: bytes */*" -bodylen 100
} -start
varnish v1 -vcl+backend {
......@@ -270,7 +279,15 @@ client c8 {
rxresp
expect resp.status == 503
txreq -url /4
txreq -url "/?unexpected=content-range"
rxresp
expect resp.status == 503
txreq -url "/?unexpected=unsatisfied-range"
rxresp
expect resp.status == 503
txreq -hdr "range: bytes=0-0" -hdr "return: pass"
rxresp
expect resp.status == 503
} -run
......@@ -288,7 +305,7 @@ varnish v1 -vcl+backend {
}
}
client c1 {
client c9 {
txreq -url /5
rxresp
expect resp.status == 200
......
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