On Mon, May 21, 2001 at 06:36:54PM +0100, Julian Gilbey wrote:
> We've just upgraded a SunOS machine from Apache 1.3.9 + mod_perl 1.21
> (dynamically linked) to Apache 1.3.19 + mod_perl 1.25 (statically
> linked).  I have a CGI/Perl script, handled as normal by perl-script
> and Apache::Registry.  Now, this CGI script sometimes returns a page
> with status something like '403 Forbidden', including full content and
> full headers.  With the old version, the perl_handler function
> returned with status=0 (OK), even if the HTTP status was going to be
> 403, and then Apache was quite happy with this.  However, in the
> current combination, the perl_handler function returns with the HTTP
> status, so that the Apache core adds on its own content.

Right, here's a patch.  This line of code was erroneously removed some
time between version 1.21 and 1.25 of mod_perl.

--- Apache.xs~  Tue May 15 14:20:51 2001
+++ Apache.xs   Wed May 23 17:18:45 2001
@@ -937,6 +937,7 @@
         r->content_type = pstrdup(r->pool, type);
     send_http_header(r);
     mod_perl_sent_header(r, 1);
+    r->status = 200; /* XXX, why??? */
 
 #ifndef PERL_OBJECT
 
An improved comment might help here.  The r->status variable is used
for two distinct purposes:

(1) Once the Perl script has correctly executed (or something like
    that; the details are really confusing), and until the HTTP header
    is correctly sent, it is used to indicate the HTTP status code
    (200 = HTTP_OK, for example).

(2) After this, it is used to record the status of the Perl script.
    The perl_call_handler function in mod_perl.c takes a status value
    of 200 to mean that everything has gone OK.

(3) The HTTP procedures don't need the HTTP status code again after
    the header has been sent.

Therefore, this line of code is necessary to keep the rest of the
system correctly functioning.

So I'd recommend a comment like:
  /* mod_perl needs this to say the code has executed correctly */

   Julian

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

         Julian Gilbey, Dept of Maths, Queen Mary, Univ. of London
       Debian GNU/Linux Developer,  see http://people.debian.org/~jdg
  Donate free food to the world's hungry: see http://www.thehungersite.com/

Reply via email to