Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Make std.collect() also work for resp.http and bereq.http.
Browse files Browse the repository at this point in the history
Fixes: #1222
  • Loading branch information
daghf authored and Tollef Fog Heen committed Feb 22, 2013
1 parent 4e1fbb6 commit 6a9302c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions bin/varnishtest/tests/m00006.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ server s1 {
expect req.http.foo == "1, 2"
txresp -hdr "bar: a" -hdr "bar: b" -bodylen 1

rxreq
expect req.url == "/2"
expect req.http.baz == "1, 2"
txresp -hdr "qux: a" -hdr "qux: b" -bodylen 1
} -start

varnish v1 -vcl+backend {
Expand All @@ -14,9 +18,15 @@ varnish v1 -vcl+backend {
sub vcl_recv {
std.collect(req.http.foo);
}
sub vcl_miss {
std.collect(bereq.http.baz);
}
sub vcl_fetch {
std.collect(beresp.http.bar);
}
sub vcl_deliver {
std.collect(resp.http.qux);
}
} -start

client c1 {
Expand All @@ -25,6 +35,12 @@ client c1 {
expect resp.http.bar == "a, b"
expect resp.status == 200
expect resp.bodylen == 1

txreq -url "/2" -hdr "Baz: 1" -hdr "Baz: 2"
rxresp
expect resp.http.qux == "a, b"
expect resp.status == 200
expect resp.bodylen == 1
} -run

varnish v1 -errvcl {'beresp.http.bar': Not available in method 'vcl_recv'} {
Expand Down
11 changes: 10 additions & 1 deletion lib/libvmod_std/vmod_std.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ vmod_collect(struct req *req, const struct gethdr_s *hdr)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
if (hdr->where == HDR_REQ)
http_CollectHdr(req->http, hdr->what);
else if (hdr->where == HDR_BERESP && req->busyobj != NULL)
else if (hdr->where == HDR_BEREQ) {
AN(req->busyobj);
http_CollectHdr(req->busyobj->bereq, hdr->what);
}
else if (hdr->where == HDR_BERESP) {
AN(req->busyobj);
http_CollectHdr(req->busyobj->beresp, hdr->what);
}
else if (hdr->where == HDR_RESP) {
http_CollectHdr(req->resp, hdr->what);
}
}

0 comments on commit 6a9302c

Please sign in to comment.