read request body with http2

Maxim Dounin mdounin at mdounin.ru
Mon Oct 21 12:40:39 UTC 2019


Hello!

On Thu, Oct 17, 2019 at 04:42:54PM -0400, Ansuel wrote:

> I don't know if this is a bug or not but... yes you were right...
> 
> All the work should be done in the ngx_http_read_client_request_body
> handler, as it does duplicate the r connection to another address
> 
> What confused me is the fact that this is only done in http2 connections...
> 
> I really don't know why but all the changes i do in the read_client_request
> handler reflect to the main ngx_http_request_t struct. I thought the code
> was cleaner by having the body read in a function and parse the data from it
> in another function. 
> 
> Well this doesn't work with http2 because all the changes done in
> read_client_request handler get lost and doesn't apply to the main struct...
> 
> 
> Think this is a bug as the behavior should be similar and not change across
> http versions... 
> 
> Sorry for the bad explanation... Also i think this should be noted in the
> wiki.

It looks like you don't understand how things work.  First 
of all, when the ngx_http_read_client_request_body() function 
returns, it doesn't mean that the request body was successfully 
read, and the body handler function was already called.

You may want to start with reading more about event-driven 
programming in general.  Also, as previously suggested, you may 
want to read Development guide, it has enough information about 
how things work and how they are expected to be handled.

Also, if you want to better understand how nginx works, consider 
reading nginx source code - it is the only direct source of the 
information.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list