[dev] how to read client body data
is at rambler-co.ru
Wed Aug 22 08:59:28 MSD 2007
On Tue, Aug 21, 2007 at 10:51:18PM +0200, Manlio Perillo wrote:
> I'm tryng to understand how to read client body data for a request.
> Reading the perl module and the dav module I have found these options:
An request body may be read in two buffers, first part in
client_header_buffer_size and second part in other memory or file buffer.
This option require to store body in single buffer - memory or file.
An body should be store in file only. Even if has zero size.
An request body temporary file is not removed just after opening.
Use it if you need to temporary file name later.
If request body file still exists on the end of request processing,
then nginx will deletes it by itself.
If set temporary file will have 0660 access rights, otherwise - 0600.
The log level of warning "a client request body is buffered to a temporary
file". Can be 0 (no log), or NGX_LOG_WARN, NGX_LOG_NOTICE, etc.
> What's the meaning of these parameters?
> To read the client body data, all I have to do is to set the previous
> parameters (as I wish) and call ngx_http_read_client_request_body with a
> "secondary" handler that will receive the request object filled with the
> necessary data?
> Ihis operation is asyncronous, right?
> This is the reason why you need to call ngx_http_finalize_request from
> the "secondary" handler.
> In the end, all I need is:
> 1) if the request body length is <= client_body_buffer_size, store
> the body in *only one* memory buffer (that is, all the data stored in
> a contiguos memory block)
> 2) if the request body length is > client_body_buffer_size, store
> *all the* body in a temporary file.
> Is 1) possible?
r->request_body_in_single_buf = 1;
r->request_body_in_persistent_file = 1;
r->request_body_in_clean_file = 1;
r->request_body_file_log_level = 0;
and you will get it.
More information about the nginx