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