Skip to content

Instantly share code, notes, and snippets.

@aondio
Created September 30, 2020 07:04
Show Gist options
  • Save aondio/b9def7e360e546b2373e0e0915ad15c0 to your computer and use it in GitHub Desktop.
Save aondio/b9def7e360e546b2373e0e0915ad15c0 to your computer and use it in GitHub Desktop.
varnishtest "Get YKeys from Origin server"
server s1 {
rxreq
txresp -hdr "ykey: BOB TOM"
} -start
varnish v1 -vcl+backend {
import ykey;
sub vcl_backend_response {
ykey.add_header(beresp.http.ykey, sep=" ");
ykey.add_key("all");
set beresp.ttl = 2m;
}
sub vcl_deliver {
if (req.http.DEBUG == "true") {
# we can only expose ykey set by the origin server
# by default Varnish will copy the beresp contenxt into the resp context
# hence what in backend_resp is 'beresp.http.ykey' now it becomes
# 'resp.http.ykey'
set resp.http.debug-ykey = resp.http.ykey;
}
}
} -start
client c1 {
txreq -hdr "DEBUG: true"
rxresp
expect resp.http.ykey == "BOB TOM"
} -run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment