[master] 6e58e28 Don't send both c-l and chunked to backend for h2.
Poul-Henning Kamp
phk at FreeBSD.org
Fri Apr 7 09:46:06 CEST 2017
commit 6e58e283a4415f6bc005299c2d6230fa81295bf2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Apr 7 07:45:11 2017 +0000
Don't send both c-l and chunked to backend for h2.
Fixes #2247
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index a44d05b..87dca6e 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -473,6 +473,7 @@ h2_do_req(struct worker *wrk, void *priv)
{
struct req *req;
struct h2_req *r2;
+ const char *b;
CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC);
CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC);
@@ -483,6 +484,15 @@ h2_do_req(struct worker *wrk, void *priv)
// XXX: Have I mentioned H/2 Is hodge-podge ?
http_CollectHdrSep(req->http, H_Cookie, "; "); // rfc7540,l,3114,3120
+ if (req->req_body_status == REQ_BODY_INIT) {
+ if (!http_GetHdr(req->http, H_Content_Length, &b))
+ req->req_body_status = REQ_BODY_WITHOUT_LEN;
+ else
+ req->req_body_status = REQ_BODY_WITH_LEN;
+ } else {
+ assert (req->req_body_status == REQ_BODY_NONE);
+ }
+
req->http->conds = 1;
if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) {
AZ(req->ws->r);
@@ -517,8 +527,6 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2,
if (h2->rxf_flags & H2FF_HEADERS_END_STREAM)
req->req_body_status = REQ_BODY_NONE;
- else
- req->req_body_status = REQ_BODY_WITHOUT_LEN;
req->req_step = R_STP_TRANSPORT;
req->task.func = h2_do_req;
diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc
index 31be89b..81ad091 100644
--- a/bin/varnishtest/tests/t02005.vtc
+++ b/bin/varnishtest/tests/t02005.vtc
@@ -4,6 +4,8 @@ barrier b1 cond 2
server s1 {
rxreq
+ expect req.http.content-length == 7
+ expect req.http.transfer-encoding == <undef>
barrier b1 sync
txresp -hdr "Content-Type: text/plain" -body response
} -start
diff --git a/bin/varnishtest/tests/t02006.vtc b/bin/varnishtest/tests/t02006.vtc
index 31a5fbf..30e4ac8 100644
--- a/bin/varnishtest/tests/t02006.vtc
+++ b/bin/varnishtest/tests/t02006.vtc
@@ -4,6 +4,8 @@ barrier b1 cond 2
server s1 {
rxreq
+ expect req.http.content-length == <undef>
+ expect req.http.transfer-encoding == chunked
expect req.proto == HTTP/1.1
barrier b1 sync
txresp -hdr "Content-Type: text/plain" -body response
@@ -21,7 +23,6 @@ client c1 {
-nohdrend
txcont \
-hdr expect 100-continue \
- -hdr content-length 7 \
-nostrend
rxhdrs
More information about the varnish-commit
mailing list