Re: bytes_received?
[prev]
[thread]
[next]
[Date index for 2004/12/09]
On Thursday 9 December 2004 04:21 pm, Geoffrey Young 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.
> > $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,
Indeed it is.
> which there just doesn't seem to be an easy way to get to.
I noticed. :-)
Is it an unusual thing to ask for?
> 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.
In this case, it's done as the very first thing, so headers_out is known to be
clear (for this particular application, which is all I'm worried about).
> you might be able to glean the size from a combination of $r->the_request,
> $r->headers_in, and $r->content_length.
So:
$size = length $r->the_request
+ $r->content_length
+ length values $r->headers_in;
I'm guessing that will be faster than "length $r->as_string".
On Thursday 9 December 2004 04:27 pm, Stas Bekman wrote:
> I see. That should be relatively use to calculate with modperl2's input
> connection filter (not w/o a small overhead of course):
> http://perl.apache.org/docs/2.0/user/handlers/filters.html#Connection_Input
>_Filters
Assuming I've understood the docs, something like:
sub handler : FilterConnectionHandler {
my($f, $bb, $mode, $block, $readbytes) = @_;
my $rv = $f->next->get_brigade($bb, $mode, $block, $readbytes);
return $rv unless $rv == APR::SUCCESS;
$r->pnotes("size"=> $bb->length);
}
Though I'm not sure how you'd get hold of $r in that context. Is that likely
to be more or less overhead than the above? (I know, benchmark it to find
out. Which I'll do when I get the chance).
It's occurred to me that as the application in question is using mod_deflate
and mod_ssl that the actual data over the network is not going to match the
size of the request. So I'm curious if there's a way to get the size at
different stages. mod_deflate logs the before and after so it at least knows
internally. (If the answer is "you can't", that's fine I'm just curious).
On Thursday 9 December 2004 04:28 pm, Geoffrey Young wrote:
> > I see. That should be relatively use to calculate with modperl2's input
> > connection filter (not w/o a small overhead of course):
> > http://perl.apache.org/docs/2.0/user/handlers/filters.html#Connection_Inp
> >ut_Filters
> yup... if he's running mp2 :)
Which I am. :-)
--
To be forgiven, we must first believe in sin
- 'Innocence Maintained' Jewel
--
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