so the $f->print statement prints correct output
but the calcualtion length(output) is incorrect (since it evaluates length of this exact string "<html><head></head><body></body></html>\n" )
why is that and how to fix this ??
many thanks ./allan
# Apache/2.0.54 (Win32) mod_ssl/2.0.53 OpenSSL/0.9.7f proxy_html/2.4 mod_perl/1.999.22-dev Perl/v5.8.6 configured
# this is the actual 11 bytes of content on URL: # hello world
# $ get localhost # hello world
# $ head localhost # ... # Server: Microsoft-IIS/6.0 # Content-Length: 40 # Content-Type: text/html; charset=utf-8 # ...
# excerpt of code my $context; unless ($f->ctx) { $r->headers_out->unset( "Content-Length" ); }
$context ||= $f->ctx; my $content_length = 0; my $str = "";
while ($f->read(my $buffer, 1024)) { $buffer = $context->{extra} . $buffer if $context->{extra}; if (($context->{extra}) = $buffer =~ m/(<[^>]*)$/) { $buffer = substr($buffer, 0, - length($context->{extra})); } $str .= $buffer; }
if ($f->seen_eos) { if ( $context->{extra} ) { $str .= $context->{extra}; } }
else { $f->ctx($context); }
$str = Rewrite::replace_links ( $str ); # at this point $str equals: <html><head></head><body></body></html>
$content_length += length( $str );
# set header $r->err_headers_out->set('Content-Length', $content_length );
$f->print( $str ); # at this point $str equals: all 42KB of correct html