Welcome! Log In Create A New Profile

Advanced

Re: Trouble getting the Request Body of a HTTP Post

Maxim Dounin
December 17, 2009 12:44PM
Hello!

On Thu, Dec 17, 2009 at 11:35:16AM -0500, Tronman wrote:

> I recently created a custom Nginx module, and successfully compiled it into the Nginx source and used a location directive to direct traffic to my module (good job me).
>
> In my modules handler, I of course have access to the ngx_http_request_t *r object passed into the function.

[...]

> So ultimately it comes down to:
> 1. Why isn't the response body in r->response_body like I would expect?

Your expectation is wrong. Handler functions are called before
request body has been read from client.

If you expect request body and want to read it, you should use
ngx_http_read_client_request_body().

> 2. Would it be safe to access it by looking past request_line.data, and if so, how do I know the total header length?

No.

> 3. Is there another method I should be using to access the response body?

You mean request body? Use ngx_http_read_client_request_body().

> 3. Any other advice you might have would be welcome!

To see the difference between (2) and (3) you may consider using
some big POST (e.g. 10M) slowly uploaded by client. This also
should give you some idea about how to handle multiple request
body buffers and disk-buffered data.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Trouble getting the Request Body of a HTTP Post

Tronman December 17, 2009 11:35AM

Re: Trouble getting the Request Body of a HTTP Post

Maxim Dounin December 17, 2009 12:44PM

Re: Trouble getting the Request Body of a HTTP Post

Tronman December 17, 2009 01:58PM

Re: Trouble getting the Request Body of a HTTP Post

Tronman December 17, 2009 02:28PM

Re: Trouble getting the Request Body of a HTTP Post

Maxim Dounin December 17, 2009 02:32PM

Re: Trouble getting the Request Body of a HTTP Post

Tronman December 17, 2009 03:33PM

Re: Trouble getting the Request Body of a HTTP Post

barretto_chris February 08, 2011 06:38PM

Re: Trouble getting the Request Body of a HTTP Post

Nick Pearson December 17, 2009 03:50PM

Re: Trouble getting the Request Body of a HTTP Post

Maxim Dounin December 17, 2009 05:02PM

Re: Trouble getting the Request Body of a HTTP Post

Tronman December 18, 2009 08:32AM



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