Commit bb75c9cd authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Don't add another Connection: header if we already have one,

but do insist on it being "close" if we need that.

Test case by daghf

Fixes #1613
parent 969674dc
......@@ -142,8 +142,13 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode);
http_SetHeader(req->resp,
req->doclose ? "Connection: close" : "Connection: keep-alive");
if (req->doclose) {
if (!http_HdrIs(req->resp, H_Connection, "close")) {
http_Unset(req->resp, H_Connection);
http_SetHeader(req->resp, "Connection: close");
}
} else if (!http_GetHdr(req->resp, H_Connection, NULL))
http_SetHeader(req->resp, "Connection: keep-alive");
VDP_push(req, v1d_bytes, NULL, 1);
......
varnishtest "Extra Connection header erroneously inserted."
server s1 {
rxreq
txresp
} -start
varnish v2 -vcl+backend {
sub vcl_deliver {
set resp.http.Connection = "close";
}
} -start
varnish v1 -vcl {
import ${vmod_std};
backend b {
.host = "${v2_addr}";
.port = "${v2_port}";
}
sub vcl_backend_response {
std.collect(beresp.http.Connection);
set beresp.http.foo = beresp.http.Connection;
}
} -start
client c1 {
txreq
rxresp
expect resp.http.foo == "close"
} -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