Welcome! Log In Create A New Profile

Advanced

Re: Add patch in ngx_http_request_body.c which enhances the request body filter module

Maxim Dounin
August 14, 2019 09:10AM
Hello!

On Tue, Aug 13, 2019 at 03:31:19AM +0000, 黎 红波 wrote:

> Hello, I found the Nginx is not considered completely for request body filter. So I submit my patch. I hope my patch could be accepted and merged under your careful consideration.
>
> Thank you!

> # HG changeset patch
> # User Hongbo Li <lihb2113@outlook.com>
> # Date 1565599828 -28800
> # Mon Aug 12 16:50:28 2019 +0800
> # Node ID 21e669b708e8e35a1f2d3d3cf72eb62cada0a347
> # Parent fcd92ad76b7bb04b46c4b8fdfe14b6065acadf7d
> Allowed self-defined request body filter module return AGAIN.
>
> When adding self-defined request body filter module, such as upload limit module, Nginx will return NGX_HTTP_INTERNAL_SERVER_ERROR if the added request body filter module return AGAIN at the same time all request body only in buffer (with request_body_no_buffering is 0). This will cause reading request body repeatedly until timeout. We should judge whether it is the last part of request body.
>
> diff -r fcd92ad76b7b -r 21e669b708e8 src/http/ngx_http_request_body.c
> --- a/src/http/ngx_http_request_body.c Thu Aug 01 13:50:07 2019 +0300
> +++ b/src/http/ngx_http_request_body.c Mon Aug 12 16:50:28 2019 +0800
> @@ -306,6 +306,10 @@
> }
> }
>
> + if (rb->rest == 0) {
> + break;
> + }
> +
> if (rb->busy != NULL) {
> if (r->request_body_no_buffering) {
> if (c->read->timer_set) {

Request body filters are not allowed to return NGX_AGAIN, and
doing so will break things. While your patch might somewhat
improve things, it certainly doesn't make it possible for request
body filters to return NGX_AGAIN: for example, HTTP/2 code simply
doesn't tolerate anything but NGX_OK.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Add patch in ngx_http_request_body.c which enhances the request body filter module Attachments

黎 红波 93 August 12, 2019 11:32PM

Re: Add patch in ngx_http_request_body.c which enhances the request body filter module

Maxim Dounin 43 August 14, 2019 09:10AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 366
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready