Commit 0b297f64 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

req: Add a Via header entry

> A proxy MUST send an appropriate Via header field, as described
> below, in each message that it forwards.

See rfc9110/7.6.3.
parent 58b15515
......@@ -873,6 +873,7 @@ cnt_recv_prep(struct req *req, const char *ci)
* it in the VSL log.
*/
http_AppendHeader(req->http, H_X_Forwarded_For, ci);
http_AppendHeader(req->http, H_Via, http_ViaHeader());
http_CollectHdr(req->http, H_Cache_Control);
/* By default we use the first backend */
......
......@@ -9,6 +9,8 @@ server s1 {
varnish v1 -vcl+backend {
sub vcl_recv {
# make PipeAcct deterministic
unset req.http.via;
return (pipe);
}
......
......@@ -11,6 +11,10 @@ server s1 {
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
# make BereqAcct deterministic
unset req.http.via;
}
sub vcl_backend_fetch {
unset bereq.http.x-forwarded-for;
unset bereq.http.x-varnish;
......
......@@ -2,6 +2,8 @@ varnishtest "Append configurable Via header"
server s1 {
rxreq
expect req.http.via == \
"1.1 v2 (Varnish/${pkg_branch}), 1.1 v1 (Varnish/${pkg_branch})"
txresp
} -start
......
......@@ -189,6 +189,7 @@ logexpect l1012 -v v1 -g vxid -q "vxid == 1012" {
expect 0 = BereqHeader {^foo: pipe}
expect 0 = BereqHeader {^Host: }
expect 0 = BereqHeader {^X-Forwarded-For: }
expect 0 = BereqHeader {^Via: }
expect 0 = BereqHeader {^X-Varnish: 1011}
expect 0 = BereqHeader {^Connection: close}
expect 0 = BereqAcct {^0 0 0 0 0 0}
......@@ -207,6 +208,7 @@ logexpect l1011 -v v1 -g vxid -q "vxid == 1011" {
expect 0 = ReqHeader {^foo: pipe}
expect 0 = ReqHeader {^Host: }
expect 0 = ReqHeader {^X-Forwarded-For: }
expect 0 = ReqHeader {^Via: }
expect 0 = VCL_call {^RECV}
expect 0 = VCL_return {^pipe}
expect 0 = VCL_call {^HASH}
......
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