Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 6161 invoked from network); 9 Dec 2004 21:24:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 9 Dec 2004 21:24:39 -0000 Received: (qmail 46174 invoked by uid 500); 9 Dec 2004 21:24:14 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 46107 invoked by uid 500); 9 Dec 2004 21:24:14 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 46052 invoked by uid 99); 9 Dec 2004 21:24:13 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Message-ID: <41B8C1EA.4000803@modperlcookbook.org> Date: Thu, 09 Dec 2004 16:21:46 -0500 From: Geoffrey Young User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040927 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stas Bekman CC: Malcolm J Harwood , modperl@perl.apache.org Subject: Re: bytes_received? References: <200412091041.56654.mjhlist-modperl@liminalflux.net> <41B8ABAE.1020100@stason.org> In-Reply-To: <41B8ABAE.1020100@stason.org> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Stas Bekman wrote: > Malcolm J Harwood wrote: > >> Is there an equivalent of Apache::RequestRec::bytes_sent for the size >> of the incoming request? (I have a situation where I need to log the >> size of the data transfer each way to a db). I've searched through the >> docs (and google) and not found anything. > > > >> The closest I've found to getting this is "length $r->as_string;" >> which is ugly and likely very inefficient. Is there a better way? > > > $ENV{CONTENT_LENGTH} or $r->headers_in->{CONTENT_LENGTH}? Of course it's > not guaranteed that it'll be set. I don't think those are the same. the Content-Length header is an entity header - for the request it should represent the size of the message body IIRC. I think what Malcolm is after is the size of the initial request, message body, headers, and all, which there just doesn't seem to be an easy way to get to. Malcolm: keep in mind that $r->as_string may not be accurate, since it simply loops through all the header tables, including the outbound headers - if someone has put something in headers_out, even before the content has been sent, it will show up. you might be able to glean the size from a combination of $r->the_request, $r->headers_in, and $r->content_length. HTH --Geoff -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html