Commit b663b4de authored by Geoff Simmons's avatar Geoff Simmons

Add a test case for injection of cookies in Set-Cookie headers into

the Cookie headers of ESI-included requests.
parent f8914faa
varnishtest "vtstor-vmod: inject cookies from Set-Cookie into ESI requests"
server s1 {
rxreq
expect req.url == "/including1"
txresp -status 200 -hdr "Set-Cookie: foo=bar" -body {
<esi:include src="/included1"/>
}
rxreq
expect req.url == "/included1"
expect req.http.Cookie == "foo=bar"
txresp
rxreq
expect req.url == "/including2"
txresp -status 200 -hdr "Set-Cookie: baz=quux" -body {
<esi:include src="/included2"/>
}
rxreq
expect req.url == "/included2"
expect req.http.Cookie == "baz=quux"
txresp
} -start
varnish v1 -vcl+backend {
import vtstor from "${vmod_topbuild}/src/.libs/libvmod_vtstor.so";
import std;
sub vcl_init {
new inst = vtstor.vtstor();
}
sub vcl_recv {
set req.http.X-VXID = vtstor.vxid();
unset req.http.X-Cookie-Inject;
set req.http.X-Cookie-Inject = inst.get(req.http.X-VXID);
if (req.http.X-Cookie-Inject != "" && req.http.Cookie) {
set req.http.Cookie = req.http.Cookie + ";"
+ req.http.X-Cookie-Inject;
}
elsif (req.http.X-Cookie-Inject != "") {
set req.http.Cookie = req.http.X-Cookie-Inject;
}
unset req.http.X-Cookie-Inject;
}
sub vcl_backend_response {
set beresp.do_esi = true;
if (beresp.http.Set-Cookie) {
inst.store(regsub(beresp.http.Set-Cookie,
"^.*\b(\w+\s*=\s*\w+).*$", "\1"),
bereq.http.X-VXID);
}
}
} -start
client c1 {
txreq -url "/including1"
timeout 2
rxresp
expect resp.status == 200
txreq -url "/including2"
timeout 2
rxresp
expect resp.status == 200
} -run
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