diff --git a/doc/plugin_core.xml b/doc/plugin_core.xml index 20ab07c..84d5659 100644 --- a/doc/plugin_core.xml +++ b/doc/plugin_core.xml @@ -100,6 +100,15 @@ + + require Content-Length for POST requests + true + + + Some clients don't send Content-Length for POST requests with empty body; they should send @Content-Length: 0@. When this check is enabled they'll get a @411 Length required@ error. + + + don't deliver static files with one of the listed extensions diff --git a/include/lighttpd/plugin_core.h b/include/lighttpd/plugin_core.h index 3c84c38..e29f0a8 100644 --- a/include/lighttpd/plugin_core.h +++ b/include/lighttpd/plugin_core.h @@ -17,7 +17,9 @@ enum liCoreOptions { LI_CORE_OPTION_ASYNC_STAT, - LI_CORE_OPTION_BUFFER_ON_DISK_REQUEST_BODY + LI_CORE_OPTION_BUFFER_ON_DISK_REQUEST_BODY, + + LI_CORE_OPTION_STRICT_POST_CONTENT_LENGTH, }; enum liCoreOptionPtrs { diff --git a/src/main/plugin_core.c b/src/main/plugin_core.c index 063c81f..bcfd669 100644 --- a/src/main/plugin_core.c +++ b/src/main/plugin_core.c @@ -2079,6 +2079,8 @@ static const liPluginOption options[] = { { "buffer_request_body", LI_VALUE_BOOLEAN, TRUE, NULL }, + { "strict.post_content_length", LI_VALUE_BOOLEAN, TRUE, NULL }, + { NULL, 0, 0, NULL } }; diff --git a/src/main/request.c b/src/main/request.c index 7c5bdd8..a458b1d 100644 --- a/src/main/request.c +++ b/src/main/request.c @@ -1,5 +1,6 @@ #include +#include #include void li_request_init(liRequest *req) { @@ -292,10 +293,14 @@ gboolean li_request_validate_header(liConnection *con) { /* content-length or chunked encoding is required for them */ if (con->mainvr->request.content_length == -1 && !transfer_encoding_chunked) { /* content-length is missing */ - VR_ERROR(con->mainvr, "%s", "POST-request, but content-length missing -> 411"); + if (_CORE_OPTION(con->mainvr, LI_CORE_OPTION_STRICT_POST_CONTENT_LENGTH).boolean) { + VR_ERROR(con->mainvr, "%s", "POST-request, but content-length missing -> 411"); - bad_request(con, 411); /* Length Required */ - return FALSE; + bad_request(con, 411); /* Length Required */ + return FALSE; + } else { + con->mainvr->request.content_length = 0; + } } break; default: