Welcome! Log In Create A New Profile

Advanced

Re: read request body with http2

Maxim Dounin
October 14, 2019 10:26AM
Hello!

On Sun, Oct 13, 2019 at 08:47:16PM -0400, Ansuel wrote:

> Hello, i'm developing a custom module that needs to read the request body to
> get some data from it.
> To read the request body i'm using
>
> ngx_http_read_client_request_body
>
> and in the callback i use
>
> for (in = r->request_body->bufs; in; in = in->next) {
> len = ngx_buf_size(in->buf);
> ngx_memcpy(buffer + pos,in->buf->pos,len);
> pos += len;
> }
>
> To put the data in a char buffer

Note that unless you've specifically tuned client_body_buffer_size
and client_max_body_size, there can be in-file buffers in
r->request_body->bufs.

> Aside from the fact that put request body in a buffer is wrong because it
> can became very big...
>
> I notice that if i enable http2 connection, the request body doesn't get
> read at all.... I notice the function read_client_request_body is never
> called...
> Am i missing something or there are some specail way to wait/read the
> request body with http2? By disabling it (remove support from nginx.conf)
> the module works as it should and i can correctly read the request body.

There is no "read_client_request_body" function in nginx. If
that's how you've called your handler function you pass into
ngx_http_read_client_request_body(), and it's never called -
probably there is something wrong with how you handle things.

Consider looking at the examples at the examples at the
Developer's Guide, probably you'll be able to find out what you've
did wrong, and/or will be able to reimplement it correctly from
scratch:

http://nginx.org/en/docs/dev/development_guide.html#http_request_body

> I really hope this can be solved as i don't want to remove http2 support for
> this...

Certainly reading request body works fine with HTTP/2, and it is
used in many standard modules, including proxy.

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

read request body with http2

Ansuel October 13, 2019 08:47PM

Re: read request body with http2

Maxim Dounin October 14, 2019 10:26AM

Re: read request body with http2

Ansuel October 14, 2019 02:41PM

Re: read request body with http2

Maxim Dounin October 15, 2019 10:58AM

Re: read request body with http2

Ansuel October 17, 2019 04:42PM

Re: read request body with http2

Maxim Dounin October 21, 2019 08:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 292
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready