From 4c1b9fef65e9a992933ae0168e62bba279eabfab Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Mon, 11 Apr 2016 18:42:34 +0300 Subject: [PATCH] FastCGI: skip special bufs in buffered request body chain. This prevents forming empty records out of such buffers. Particularly it fixes double end-of-stream records with chunked transfer encoding, or when HTTP/2 is used and the END_STREAM flag has been sent without data. In both cases there is an empty buffer at the end of the request body chain with the "last_buf" flag set. The canonical libfcgi, as well as php implementation, tolerates such records, while the HHVM parser is more strict and drops the connection (ticket #950). --- src/http/modules/ngx_http_fastcgi_module.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c index a86120377..2d288ce93 100644 --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -1177,6 +1177,11 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r) while (body) { + if (ngx_buf_special(body->buf)) { + body = body->next; + continue; + } + if (body->buf->in_file) { file_pos = body->buf->file_pos;