[PATCH] HTTP/2: add fast-path for HTTP/2 requests without request body

Valentin V. Bartenev vbart at nginx.com
Tue Mar 28 19:56:30 UTC 2017


On Sunday 26 March 2017 01:41:23 Piotr Sikora via nginx-devel wrote:
> # HG changeset patch
> # User Piotr Sikora <piotrsikora at google.com>
> # Date 1490516712 25200
> #      Sun Mar 26 01:25:12 2017 -0700
> # Node ID f9fd6a8babce9f57f038d304dc1eef82284dde8b
> # Parent  22be63bf21edaa1b8ea916c7d8cd4e5fe4892061
> HTTP/2: add fast-path for HTTP/2 requests without request body.
> 
> Signed-off-by: Piotr Sikora <piotrsikora at google.com>
> 
> diff -r 22be63bf21ed -r f9fd6a8babce src/http/v2/ngx_http_v2.c
> --- a/src/http/v2/ngx_http_v2.c
> +++ b/src/http/v2/ngx_http_v2.c
> @@ -3494,7 +3494,9 @@ ngx_http_v2_read_request_body(ngx_http_r
>  
>      stream = r->stream;
>  
> -    if (stream->skip_data) {
> +    if (stream->skip_data
> +        || (stream->in_closed && stream->preread == NULL))
> +    {
>          r->request_body_no_buffering = 0;
>          post_handler(r);
>          return NGX_OK;

That doesn't look like a correct patch to me as it changes behavior
of ngx_http_read_client_request_body() specifically for HTTP/2 case.

Note, that in case of HTTP/1.x it always allocates r->request_body
for the main request unless r->discard_body is set.

Even if it doesn't break something in nginx at the first glance,
there's always a chance that some 3rd-party modules can depend
on this.

Anyway, this change should be made either for both protocols or
for none of them.

  wbr, Valentin V. Bartenev



More information about the nginx-devel mailing list