[master] 1d9d85e Collect H2 cookies in H2 code, long time before we get to create req->http0.

Poul-Henning Kamp phk at FreeBSD.org
Wed Apr 5 08:47:05 CEST 2017


commit 1d9d85eb0cd32c55712e8dabe00f1249ce502ca3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Apr 5 06:45:08 2017 +0000

    Collect H2 cookies in H2 code, long time before we get to create req->http0.
    
    Fixes #2300
    
    Testcase by Simon

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 1723bed..1320e81 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -799,9 +799,6 @@ cnt_recv(struct worker *wrk, struct req *req)
 
 	http_CollectHdr(req->http, H_Cache_Control);
 
-	if (req->http->protover == 20) // rfc7540,l,3114,3120
-		http_CollectHdrSep(req->http, H_Cookie, "; ");
-
 	if (req->req_body_status == REQ_BODY_FAIL) {
 		req->doclose = SC_OVERLOAD;
 		return (REQ_FSM_DONE);
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index ab0f28d..27c95bd 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -467,6 +467,12 @@ h2_do_req(struct worker *wrk, void *priv)
 	CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC);
 	CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC);
 	THR_SetRequest(req);
+
+	// XXX: Smarter to do this already at HPACK time into tail end of
+	// XXX: WS, then copy back once all headers received.
+	// XXX: Have I mentioned H/2 Is hodge-podge ?
+	http_CollectHdrSep(req->http, H_Cookie, "; ");	// rfc7540,l,3114,3120
+
 	req->http->conds = 1;
 	if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) {
 		AZ(req->ws->r);
diff --git a/bin/varnishtest/tests/r02300.vtc b/bin/varnishtest/tests/r02300.vtc
new file mode 100644
index 0000000..130a172
--- /dev/null
+++ b/bin/varnishtest/tests/r02300.vtc
@@ -0,0 +1,29 @@
+varnishtest "ESI Cookie"
+
+server s1 {
+	fatal
+	rxreq
+	expect req.http.cookie == "Foo=Bar; B=C"
+	txresp -body "<html><esi:include src='/esi_test'/>"
+
+	rxreq
+	expect req.http.cookie == "Foo=Bar; B=C"
+	txresp
+} -start
+
+varnish v1 -cliok {param.set feature +http2}
+varnish v1 -cliok {param.set debug +syncvsl}
+
+
+varnish v1 -vcl+backend  {
+	sub vcl_backend_response {
+		set beresp.do_esi = true;
+	}
+} -start
+
+client c1 {
+	stream 1 {
+		txreq -url "/" -hdr cookie "Foo=Bar" -hdr cookie "B=C"
+		rxresp
+	} -start
+} -run



More information about the varnish-commit mailing list