Trouble getting the Request Body of a HTTP Post

Tronman nginx-forum at nginx.us
Fri Dec 18 16:32:52 MSK 2009


Nick Pearson Wrote:
-------------------------------------------------------
> curl is a good way to test URLs without having to
> re-type everything
> each time.  You can POST by using the -d or -f
> option.  Much better
> than telnet for this type of testing, in my
> experience.

Yes, I've heard of cURL but hadn't used it a whole lot. I've installed it and will give it a try, thanks!

Maxim Dounin Wrote:
-------------------------------------------------------
> You should use ->bufs.  Here is the comment from 
> ngx_http_request_body.c which should be helpful:
> 
> /*
>  * on completion
> ngx_http_read_client_request_body() adds to
>  * r->request_body->bufs one or two bufs:
>  *    *) one memory buf that was preread in
> r->header_in;
>  *    *) one memory or file buf that contains the
> rest of the body
>  */
> 
> Simple example of using request_body may be found
> in 
> ngx_http_variables.c, in function 
> ngx_http_variable_request_body().
> 

Ah, I was looking for something like that. Thanks!

> 
> > So if I specify "client_body_in_single_buffer"
> as "true", does 
> > it store the entire client request in
> r->request_body->buf?
> 
> No.  It will be in first buffer of
> r->request_body->bufs, either 
> in memory if it fits into client_body_buffer_size
> or in file.
> 
> > But if not, does it separate the client request
> body into the 
> > chunks of whatever client_body_buffer_size is
> set to, and then 
> > you use the chain to gain access to the entire
> thing?
> 
> Not exactly.  Currently r->request_body->bufs will
> contain up to two 
> buffers: one for data preread with headers, and
> one for data got 
> later.  If there are more data than
> client_body_buffer_size - the 
> last buffer will be in temporary file.
> 
> It's probably a good idea to spend some time
> reading 
> ngx_http_request_body.c for better clue what
> happens in various 
> cases.

> Maxim Dounin

Gotcha. I think I'm getting a handle on what's going on. Thanks again for all your help!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,31312,31612#msg-31612




More information about the nginx mailing list