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:
request_body_in_single_buf
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.
request_body_in_file_only
An body should be store in file only. Even if has zero size.
request_body_in_persistent_file
An request body temporary file is not removed just after opening.
Use it if you need to temporary file name later.
request_body_in_clean_file
If request body file still exists on the end of request processing,
then nginx will deletes it by itself.
request_body_file_group_access
If set temporary file will have 0660 access rights, otherwise - 0600.
request_body_file_log_level
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.
Yes.
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?
Yes, use
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.