Subject: | PLP sends headers before it's due |
PLP will send the headers whenever an inline include is made, whether or not the included files printed anything.
For example:
<(init.pl)><: $headers{location} = 'someurl' :>
will give an error about the headers being already sent, even if init.pl was totally empty (0 length) and the above was the very first thing in the file.
The fix is pretty easy, the diff is at the end of this message.
Basically, the print function would call send_headers when it got two empty strings.
*** /usr/lib/perl5/site_perl/5.6.1/PLP.pm Mon Aug 11 19:21:35 2003
--- PLP.pm Fri Oct 18 15:47:07 2002
***************
*** 174,180 ****
# FAST printing under mod_perl
sub mod_perl_print {
! return if @_ > 0 and not length join(undef,@_);
PLP::sendheaders() unless $PLP::sentheaders;
$PLP::r->print(@_);
}
--- 172,178 ----
# FAST printing under mod_perl
sub mod_perl_print {
! return if @_ == 1 and not length $_[0];
PLP::sendheaders() unless $PLP::sentheaders;
$PLP::r->print(@_);
}
*** /usr/lib/perl5/site_perl/5.6.1/PLP/Tie/Print.pm Mon Aug 11 19:22:08 2003
--- PLP/Tie/Print.pm Wed Aug 21 12:54:45 2002
***************
*** 18,24 ****
sub PRINT {
shift;
! return if @_ > 0 and not length join(undef,@_);
PLP::sendheaders() unless $PLP::sentheaders;
print STDOUT @_;
select STDOUT;
--- 18,24 ----
sub PRINT {
shift;
! return if @_ == 1 and not length $_[0];
PLP::sendheaders() unless $PLP::sentheaders;
print STDOUT @_;
select STDOUT;