Commit a99ce697 authored by Nils Goroll's avatar Nils Goroll

Update to explicit std.fetch_body(deliver)

parent 5301a92e
Pipeline #401 skipped
...@@ -132,7 +132,7 @@ vfp_bodyhash_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) ...@@ -132,7 +132,7 @@ vfp_bodyhash_fini(struct vfp_ctx *vc, struct vfp_entry *vfe)
*p++ = '\0'; *p++ = '\0';
assert(pdiff(hex, p) == hexl); assert(pdiff(hex, p) == hexl);
if (vc->resp && vc->resp->thd) { if (vc->resp) {
http_ForceHeader(vc->resp, H_ETag, hex); http_ForceHeader(vc->resp, H_ETag, hex);
goto out; goto out;
} }
......
...@@ -18,9 +18,9 @@ capabilities like: ...@@ -18,9 +18,9 @@ capabilities like:
* generate ``ETag`` backend response headers * generate ``ETag`` backend response headers
* track the most recent ``Last-Modified`` date of all ESI includes. * track the most recent ``Last-Modified`` date of all ESI includes.
It requires chunked encoding trailer support, which, as of 2017-11-06, It requires chunked encoding trailer support, which, as of 2017-11-23,
has not been merged to varnish-cache. See has not been merged to varnish-cache. See
https://github.com/varnishcache/varnish-cache/pull/2477 https://github.com/nigoroll/varnish-cache/pull/6
Example Example
:: ::
......
...@@ -39,9 +39,15 @@ server s1 { ...@@ -39,9 +39,15 @@ server s1 {
txresp \ txresp \
-hdr "Last-Modified: Fri, 03 Nov 2017 18:38:04 GMT" \ -hdr "Last-Modified: Fri, 03 Nov 2017 18:38:04 GMT" \
-body {<html></html>} -body {<html></html>}
rxreq
expect req.url == "/nobody"
txresp -status 302 -body {}
} -start } -start
varnish v1 -arg "-p feature=+esi_disable_xml_check" -vcl+backend {} -start varnish v1 -arg "-p feature=+esi_disable_xml_check" \
-arg "-p debug=+syncvsl" \
-vcl+backend {} -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import esiextra; import esiextra;
...@@ -175,6 +181,7 @@ varnish v1 -vcl+backend { ...@@ -175,6 +181,7 @@ varnish v1 -vcl+backend {
} else { } else {
set beresp.http.Trailer = "ETag"; set beresp.http.Trailer = "ETag";
} }
std.fetch_body(deliver);
return (deliver); return (deliver);
} }
set beresp.http.Vary = "X-TE"; set beresp.http.Vary = "X-TE";
...@@ -239,6 +246,17 @@ client c1 { ...@@ -239,6 +246,17 @@ client c1 {
expect resp.http.Last-Modified == "Fri, 03 Nov 2017 18:38:04 GMT" expect resp.http.Last-Modified == "Fri, 03 Nov 2017 18:38:04 GMT"
expect resp.http.ETag == {"b633a587c652d02386c4f16f8c6f6aab7352d97f16367c3c40576214372dd628"} expect resp.http.ETag == {"b633a587c652d02386c4f16f8c6f6aab7352d97f16367c3c40576214372dd628"}
expect resp.http.hits == "0,0" expect resp.http.hits == "0,0"
# response with no body
txreq -url "/nobody"
rxresp
expect resp.status == 302
expect resp.bodylen == 0
expect resp.http.Trailer == <undef>
expect resp.http.X-ESI == "/nobody"
expect resp.http.Last-Modified == <undef>
expect resp.http.ETag == {"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
expect resp.http.hits == "0,0"
} -run } -run
varnish v1 -expect esi_errors == 0 varnish v1 -expect esi_errors == 0
logexpect l1 -wait logexpect l1 -wait
...@@ -24,10 +24,12 @@ server s1 { ...@@ -24,10 +24,12 @@ server s1 {
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import std;
import esiextra; import esiextra;
sub vcl_backend_response { sub vcl_backend_response {
esiextra.bodyhash(beresp.http.ETag); esiextra.bodyhash(beresp.http.ETag);
std.fetch_body(deliver);
} }
} -start } -start
......
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