Here's a patch that I sent to Doug. Not sure if I would
accept something from a guy who *clearly* can't read a
simple INSTALL file... ;) Here's hoping anyway.

- Ken


I was using $request->sent_header and found out that it's
not terribly useful if PerlSendHeader is off -- sent_header
always returns 1. I changed mod_perl_sent_header so that
it returns 0, 1 or 2:

  0 - headers have not been sent (PerlSendHeader on)
  1 - headers have not been sent (PerlSendHeader off)
  2 - headers have already been sent

This won't disrupt any code that checks for a true/false
return from mod_perl_sent_header. $request->sent_header is
undocumented so I don't think much user code is using it. The
only change I'm concerned about is turning off MP_SENTHDR
for both PerlSendHeader on and off. If any code is checking
that directly (instead of using mod_perl_sent_header) then
the code may break. mod_perl itself is clean, but I haven't
checked all the Apache modules people have written.

Patch was written for version 1.21 but it works on 1.24 too.

- Ken
*** mod_perl-1.21/src/modules/perl/mod_perl.c   Thu Jul  1 14:17:38 1999
--- development/src/modules/perl/mod_perl.c     Wed Jul 19 00:14:20 2000
***************
*** 736,744 ****
  {
      dPPDIR;
  
!     if(val) MP_SENTHDR_on(cld);
!     val = MP_SENTHDR(cld) ? 1 : 0;
!     return MP_SENDHDR(cld) ? val : 1;
  }
  
  #ifndef perl_init_ids
--- 736,750 ----
  {
      dPPDIR;
  
!     if (val) {
!       MP_SENTHDR_on(cld);
!       val = 2;
!     }
!     else {
!       val = MP_SENTHDR(cld) ? 2 : 0;
!     }
! 
!     return (val) ? val : MP_SENDHDR(cld) ? 0 : 1;
  }
  
  #ifndef perl_init_ids
***************
*** 1262,1273 ****
      
      /* PerlSendHeader */
      if(MP_SENDHDR(cld)) {
-       MP_SENTHDR_off(cld);
        table_set(r->subprocess_env, 
                  "PERL_SEND_HEADER", "On");
      }
!     else
!       MP_SENTHDR_on(cld);
  
      /* SetEnv PERL5LIB */
      if(!MP_INCPUSH(cld)) {
--- 1268,1277 ----
      
      /* PerlSendHeader */
      if(MP_SENDHDR(cld)) {
        table_set(r->subprocess_env, 
                  "PERL_SEND_HEADER", "On");
      }
!     MP_SENTHDR_off(cld);
  
      /* SetEnv PERL5LIB */
      if(!MP_INCPUSH(cld)) {


Reply via email to