5 messages in ru.sysoev.nginxRe: [dev] how to read client body data
FromSent OnAttachments
Manlio PerilloAug 21, 2007 1:50 pm 
Manlio PerilloAug 21, 2007 2:13 pm 
Igor SysoevAug 21, 2007 9:59 pm 
Igor SysoevAug 21, 2007 10:01 pm 
Manlio PerilloAug 22, 2007 3:47 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [dev] how to read client body dataActions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Aug 21, 2007 9:59:05 pm
List:ru.sysoev.nginx

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.