You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Brad <br...@intradonline.com> on 2007/06/13 15:46:04 UTC
FilterRequestHandler to get partial transfer bytes
Within a PerlCleanupHandler I'm trying to get hold of how much data has
been sent for interrupted transfers. I had used $r->last->bytes_sent in
apache1 but it always just contains the whole filesize in apache2
I'm trying to use apache2 filters to get an accurate result like logio.
I have the below code that appears to work correctly counting out in
intervals of BUFF_LEN, however when the download is ended early it
continues to loop and counts up to the full filesize.
How come it doesn't stop when the download is cancelled? I know it can
be done because logio.c can do it :)
I tried a connection example off the mod_perl site and i got one small
BB, and the next BB showed the full hundred Mb filesize, so also no good
for my purpose.
sub handler : FilterRequestHandler {
my $f = shift;
my $count = 0;
while ($f->read(my $buffer, BUFF_LEN)) {
$count += length($buffer);
warn length($buffer);
$f->print($buffer);
}
warn $count;
my $r = $f->r;
$r->pnotes('count'=>$count);
Apache2::Const::OK;
}
Help greatly appreciated, I can see that these filters are a better way
of doing things, but they're a bit outta my league using them
properly :)