HTTP/2: fixed handling of fully preread request bodies.

Previously, fully preread request body of a request without the
"Content-Length" header was always written to a temporary file.

Change-Id: I996d1be9aca1b7ec6b0c139111150d0b832abb12
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Reviewed-on: https://nginx-review.googlesource.com/c/3540
Reviewed-by: Wayne Zhang <qiwzhang@google.com>
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
index 80520ee..04b3385 100644
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -3896,6 +3896,12 @@
     {
         rb->buf = ngx_create_temp_buf(r->pool, (size_t) len);
 
+    } else if (len < 0 && stream->in_closed && stream->preread
+               && !r->request_body_in_file_only)
+    {
+        rb->buf = ngx_create_temp_buf(r->pool,
+                                      (size_t) ngx_buf_size(stream->preread));
+
     } else {
         rb->buf = ngx_calloc_buf(r->pool);