From 06d3c754403b2df99775641e05999ea9b2081618 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 26 Mar 2016 12:58:33 +0000 Subject: [PATCH] [core] respond 411 Length Required if request has Transfer-Encoding: chunked (fixes #631) lighttpd does not currently support request body transfer-codings From: Glenn Strauss git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3128 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/request.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1e42932b..5db90368 100644 --- a/NEWS +++ b/NEWS @@ -52,6 +52,7 @@ NEWS * [config] warn if server.upload-dirs has non-existent dirs (fixes #2508) * [mod_proxy] accept LF delimited headers, not just CRLF (fixes #2594) * [core] wait for grandchild to be ready when daemonizing (fixes #2712, thx pasdVn) + * [core] respond 411 Length Required if request has Transfer-Encoding: chunked (fixes #631) - 1.4.39 - 2016-01-02 * [core] fix memset_s call (fixes #2698) diff --git a/src/request.c b/src/request.c index f75574fa..08047b55 100644 --- a/src/request.c +++ b/src/request.c @@ -1133,7 +1133,15 @@ int http_request_parse(server *srv, connection *con) { } break; default: - /* the may have a content-length */ + /* require Content-Length if request contains request body */ + if (array_get_element(con->request.headers, "Transfer-Encoding")) { + /* presence of Transfer-Encoding in request headers requires "chunked" + * be final encoding in HTTP/1.1. Return 411 Length Required as + * lighttpd does not support request input transfer-encodings */ + con->keep_alive = 0; + con->http_status = 411; /* 411 Length Required */ + return 0; + } break; }