[mod_proxy] pass Content-Length to backend if > 0
pass Content-Length to backend if > 0, even if GET or HEAD method
(and pass Content-Length: 0 for other methods if no request body)
@@ -752,9 +752,10 @@ static handler_t proxy_create_env(server *srv, gw_handler_ctx *gwhctx) {
/* "Forwarded" and legacy X- headers */
proxy_set_Forwarded(con, hctx->conf.forwarded);
- if (HTTP_METHOD_GET != con->request.http_method
- && HTTP_METHOD_HEAD != con->request.http_method
- && con->request.content_length >= 0) {
+ if (con->request.content_length > 0
+ || (0 == con->request.content_length
+ && HTTP_METHOD_GET != con->request.http_method
+ && HTTP_METHOD_HEAD != con->request.http_method)) {
/* set Content-Length if client sent Transfer-Encoding: chunked
* and not streaming to backend (request body has been fully received) */
buffer *vb = http_header_request_get(con, HTTP_HEADER_CONTENT_LENGTH, CONST_STR_LEN("Content-Length"));
