Skip to content

Commit

Permalink
ESI: Use response status modulo 1000
Browse files Browse the repository at this point in the history
  • Loading branch information
nigoroll authored and dridi committed Jul 13, 2023
1 parent 1295333 commit 5636ad0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
7 changes: 4 additions & 3 deletions bin/varnishd/cache/cache_esi_deliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
{
int i = 0;
const char *p;
uint16_t status;
struct ecx *ecx;
struct ved_foo foo[1];
struct vrt_ctx ctx[1];
Expand All @@ -869,9 +870,9 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
if (wantbody == 0)
return;

if (!ecx->incl_cont &&
req->resp->status != 200 &&
req->resp->status != 204) {
status = req->resp->status % 1000;

if (!ecx->incl_cont && status != 200 && status != 204) {
req->top->topreq->vdc->retval = -1;
req->top->topreq->doclose = req->doclose;
return;
Expand Down
29 changes: 20 additions & 9 deletions bin/varnishtest/tests/e00003.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ server s1 {
txresp -body {
<html>
Before include
<esi:include src="/body" sr="foo"/>
After include
<esi:include src="/body" sr="foo"/><esi:include src="/synth"/>After include
</html>
}
rxreq
Expand All @@ -21,9 +20,17 @@ server s1 {
} -start

varnish v1 -vcl+backend {
sub vcl_synth {
set resp.body = """
""";
return (deliver);
}
sub vcl_recv {
if (req.esi_level > 0) {
set req.url = req.url + req.esi_level;
if (req.url ~ "^/synth") {
return (synth(3200));
}
} else {
set req.http.esi0 = "foo";
}
Expand Down Expand Up @@ -64,7 +71,7 @@ logexpect l4 -v v1 -g request {
} -start

logexpect l5 -v v1 -g request {
expect * 1005 Begin "^req .* rxreq"
expect * 1006 Begin "^req .* rxreq"
# Header bytes is 5 larger than in l1 due to two item X-Varnish hdr
expect * = ReqAcct "^29 0 29 175 75 250$"
expect 0 = End
Expand All @@ -87,7 +94,7 @@ client c1 {
}

client c1 -run
varnish v1 -expect esi_req == 2
varnish v1 -expect esi_req == 4
varnish v1 -expect esi_errors == 0
varnish v1 -expect MAIN.s_resp_bodybytes == 150

Expand All @@ -104,7 +111,7 @@ shell {

cat >expected.txt <<-EOF
1001 c rxreq
1005 c rxreq
1006 c rxreq
EOF
diff -u expected.txt ncsa.txt
}
Expand All @@ -129,8 +136,10 @@ shell {
cat >expected.txt <<-EOF
1001 c rxreq
1003 c esi
1005 c rxreq
1006 c esi
1005 c esi
1006 c rxreq
1007 c esi
1008 c esi
EOF
diff -u expected.txt ncsa.txt
}
Expand All @@ -145,8 +154,10 @@ shell {
1002 b fetch
1003 c esi
1004 b fetch
1005 c rxreq
1006 c esi
1005 c esi
1006 c rxreq
1007 c esi
1008 c esi
EOF
diff -u expected.txt ncsa.txt
}
Expand Down

0 comments on commit 5636ad0

Please sign in to comment.