Hello,
I made a patch for openresty-1.2.4 to export all log specific variables. I sent the same patch for nginx-1.3.10 to official nginx developers.
I am attaching the one for openresty-1.2.4 here if someone need it.
Attachment:
http_variables.patch.openresty
Description: Binary data
Regards,
Kiril
On Jan 4, 2013, at 2:49 AM, agentzh wrote:
> Hello!
>
> On Thu, Jan 3, 2013 at 5:17 AM, Kiril Kalchev <ki...@cloudxcel.com> wrote:
>> I am trying to implement a basic nginx requests statistics module in lua. I
>> want to get request and response size without getting the whole response in
>> memory? As far as I can see after nginx 1.2.5 I can use bytes_sent common
>> variable from http_log_module for response size but I can't see how I can
>> get request size without getting the whole request. Any ideas what could be
>> done?
>>
>
> Case #1
>
> If the request body has not yet been read *and* chunked encoding is
> not used for the request body data, then you can just read the
> Content-Length request header (that is,
> r->headers_in.content_length_n). The request header size can be got by
> reading r->request_length directly, you need to add that up, that is,
>
> r->headers_in.content_length_n + r->request_length
>
> If chunked encoding is used for the request body, then the request
> body length cannot be known before reading it.
>
> Case #2
>
> If the request body has already been read, then you can directly read
> r->request_length (where r is the current ngx_http_request_t object)
> in C.
>
> It seems that the $request_length (fake) variable in
> ngx_http_log_module is not exported as a real nginx variable at least
> in nginx 1.2.6. The $request_length variable's get handler just reads
> r->request_length.
>
> Best regards,
> -agentzh.
>
>