You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Drew Degentesh <dd...@daed.com> on 2000/10/07 14:57:46 UTC
bytes_sent -> bytes_received?
In addition to the number of bytes sent to the client, Id like to log how
many bytes are sent *by* the client (the size of the request + posts , etc.)
I was guessing/hoping that length( scalar( $r->content ) ) would do it, but
earlier in my application (before the log phase) I use Apache::Request to
(potentially) process a file upload, and Im guessing that clears out
$r->content.
Any ideas?
........................................................................
Drew Degentesh
Senior Engineer
Daedalus Design, Inc.
ddegentesh@daed.com
Re: bytes_sent -> bytes_received?
Posted by David Alan Pisoni <da...@cnation.com>.
At 7.25 PM +0100 10/7/2000, Matthew Byng-Maddick wrote:
>On Sat, 7 Oct 2000, Drew Degentesh wrote:
>> In addition to the number of bytes sent to the client, Id like to log how
>> many bytes are sent *by* the client (the size of the request + posts , etc.)
>
>Fair enough
>
>> I was guessing/hoping that length( scalar( $r->content ) ) would do it, but
>> earlier in my application (before the log phase) I use Apache::Request to
>> (potentially) process a file upload, and Im guessing that clears out
>> $r->content.
>
>I'm not sure if it does or not. Anyhow, $r->content won't get you the full
>request, plus all the headers. The best way to do this would be to put
>your measuring code in as a URI Translation handler (with whatever method
>works.... erm...) and then put the value in a notes field which you can
>then recover later on in the processing.
>
>> Any ideas?
>
>Not very helpful, I'm afraid.
>
>MBM
>
>--
>perl -e '$_=unpack"b196",pack"H50","cafa9c0e0abbdf7474590e8296e56c103a3c".
>"5e97e52e104821";while(m(^.{7})){$a.=$&."0";$_=$'"'"'}print pack"b224",$a'
Well, if you need the length of the POST data, then you should be
able (assuming the browser follows the RFCs) to get it from
$r->header_in( 'Content-length' ).
If you need the length of the ENTIRE request, theoretically you could
get it by adding together :
1) the above value
<CODE>my $headerlength = $r->header_in( 'Content-length' )</CODE>
2) the lengths of all the header lines
<CODE>
my $headers = $r->headers_in();
map { $headerlength += length($_) + length($headers->{$_}) + 2 }
## +2 above for ': ' between the header key and value
keys %$headers;
</CODE>
3) and the request line
<CODE>$headerlength += length( $r->the_request() )</CODE>
Did I miss anything? Methinks this is the lot, but I'm just typing
here -- I didn't test it. ;-)
Enjoy,
--
David Pisoni -- <da...@cnation.com>
Cnation -- <http://www.cnation.com/>
310/228-6900 -- 310/228-6905 (fax)
"One machine can do the work of fifty ordinary men. No machine can do
the work of one extraordinary man." -Elbert Hubbard, author, editor,
printer (1856-1915)
Re: bytes_sent -> bytes_received?
Posted by Matthew Byng-Maddick <mb...@colondot.net>.
On Sat, 7 Oct 2000, Drew Degentesh wrote:
> In addition to the number of bytes sent to the client, Id like to log how
> many bytes are sent *by* the client (the size of the request + posts , etc.)
Fair enough
> I was guessing/hoping that length( scalar( $r->content ) ) would do it, but
> earlier in my application (before the log phase) I use Apache::Request to
> (potentially) process a file upload, and Im guessing that clears out
> $r->content.
I'm not sure if it does or not. Anyhow, $r->content won't get you the full
request, plus all the headers. The best way to do this would be to put
your measuring code in as a URI Translation handler (with whatever method
works.... erm...) and then put the value in a notes field which you can
then recover later on in the processing.
> Any ideas?
Not very helpful, I'm afraid.
MBM
--
perl -e '$_=unpack"b196",pack"H50","cafa9c0e0abbdf7474590e8296e56c103a3c".
"5e97e52e104821";while(m(^.{7})){$a.=$&."0";$_=$'"'"'}print pack"b224",$a'