[master] 9ab5669 Remove any C-L header if T-E: chunked is present.
Poul-Henning Kamp
phk at FreeBSD.org
Tue May 5 11:50:58 CEST 2015
commit 9ab5669b8684add053650ff724cfe75cecfa324b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue May 5 09:50:03 2015 +0000
Remove any C-L header if T-E: chunked is present.
Fixes: #1729
diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c
index 29110fb..fc20bae 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -263,7 +263,7 @@ http1_splitline(struct http *hp, const struct http_conn *htc, const int *hf)
/*--------------------------------------------------------------------*/
static enum body_status
-http1_body_status(const struct http *hp, struct http_conn *htc)
+http1_body_status(struct http *hp, struct http_conn *htc)
{
ssize_t cl;
const char *b;
@@ -273,8 +273,10 @@ http1_body_status(const struct http *hp, struct http_conn *htc)
htc->content_length = -1;
- if (http_HdrIs(hp, H_Transfer_Encoding, "chunked"))
+ if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
+ http_Unset(hp, H_Content_Length);
return (BS_CHUNKED);
+ }
if (http_GetHdr(hp, H_Transfer_Encoding, &b))
return (BS_ERROR);
diff --git a/bin/varnishtest/tests/r01729.vtc b/bin/varnishtest/tests/r01729.vtc
new file mode 100644
index 0000000..dd7e0da
--- /dev/null
+++ b/bin/varnishtest/tests/r01729.vtc
@@ -0,0 +1,75 @@
+varnishtest "C-L/T-E:chunked conflict"
+
+server s1 {
+ rxreqhdrs
+ expect req.http.content-length == <undef>
+ expect req.http.transfer-encoding == chunked
+ rxreqbody
+ expect req.url == /1
+ expect req.bodylen == 20
+
+ send "HTTP/1.1 200 OK"
+ send "Content-Length: 31\r\n"
+ send "Transfer-Encoding: chunked\r\n"
+ send "\r\n"
+ send "14\r\n"
+ send "0123456789"
+ send "0123456789"
+ send "0\r\n"
+ send "\r\n"
+
+ rxreqhdrs
+ expect req.http.content-length == 20
+ expect req.http.transfer-encoding == <undef>
+ expect req.url == /2
+ expect req.bodylen == 20
+
+ send "HTTP/1.1 200 OK"
+ send "Content-Length: 31\r\n"
+ send "Transfer-Encoding: chunked\r\n"
+ send "\r\n"
+ send "14\r\n"
+ send "0123456789"
+ send "0123456789"
+ send "0\r\n"
+ send "\r\n"
+
+} -start
+
+varnish v1 -vcl+backend {
+ import ${vmod_std};
+ sub vcl_recv {
+ if (req.url == "/2") {
+ std.cache_req_body(1KB);
+ }
+ }
+} -start
+
+client c1 {
+
+ send "PUT /1 HTTP/1.1\r\n"
+ send "Content-Length: 31\r\n"
+ send "Transfer-Encoding: chunked\r\n"
+ send "\r\n"
+ send "14\r\n"
+ send "0123456789"
+ send "0123456789"
+ send "0\r\n"
+ send "\r\n"
+ rxresp
+ expect resp.bodylen == 20
+
+
+ send "PUT /2 HTTP/1.1\r\n"
+ send "Content-Length: 31\r\n"
+ send "Transfer-Encoding: chunked\r\n"
+ send "\r\n"
+ send "14\r\n"
+ send "0123456789"
+ send "0123456789"
+ send "0\r\n"
+ send "\r\n"
+ rxresp
+ expect resp.bodylen == 20
+
+} -run
More information about the varnish-commit
mailing list