Skip to content

Commit

Permalink
Don't error on short range response
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil committed Dec 14, 2022
1 parent eec2a6b commit 535a5f0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion bin/varnishd/cache/cache_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ vrg_range_fini(struct vdp_ctx *vdc, void **priv)

CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
CAST_OBJ_NOTNULL(vrg_priv, *priv, VRG_PRIV_MAGIC);
if (vrg_priv->range_off < vrg_priv->range_high) {
if (vrg_priv->req->resp_len >= 0 &&
vrg_priv->range_off < vrg_priv->range_high) {
Req_Fail(vrg_priv->req, SC_RANGE_SHORT);
vrg_priv->req->vdc->retval = -1;
}
Expand Down
19 changes: 11 additions & 8 deletions bin/varnishtest/tests/r01506.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ varnishtest "range requests on streamed response"

barrier b1 cond 2 -cyclic

server s1 -repeat 4 {
server s1 -repeat 5 {
rxreq
txresp -nolen \
-hdr "Transfer-Encoding: chunked" \
Expand All @@ -24,11 +24,6 @@ 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
Expand Down Expand Up @@ -65,7 +60,15 @@ client c1 {
barrier b1 sync
rxrespbody
expect resp.bodylen == 34
delay .1

# Keeps working after short response
txreq -url /5 -hdr "Range: bytes=17-101"
rxresphdrs
expect resp.status == 206
barrier b1 sync
rxrespbody
expect resp.bodylen == 85
} -run

varnish v1 -expect sc_range_short == 1
logexpect l1 -wait
varnish v1 -expect sc_range_short == 0
8 changes: 8 additions & 0 deletions bin/varnishtest/tests/r02258.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ server s1 {

varnish v1 -vcl+backend { } -start

logexpect l1 -v v1 -g session {
expect 0 1000 Begin sess
expect * = SessClose RANGE_SHORT
} -start

client c1 {
txreq -hdr "range: bytes=0-16"
rxresp -no_obj
Expand All @@ -24,6 +29,7 @@ client c1 {
} -run

varnish v1 -expect MAIN.sc_range_short == 1
logexpect l1 -wait

delay .3

Expand All @@ -43,3 +49,5 @@ client c2 {
expect rst.err == INTERNAL_ERROR
} -run
} -run

varnish v1 -expect MAIN.sc_range_short == 1

0 comments on commit 535a5f0

Please sign in to comment.