Re: Logging real HTTP status

2000-09-28 Thread Doug MacEachern

On Wed, 13 Sep 2000, brian d foy wrote:

 
 let's suppose that i want to change the HTTP status to be something other
 than i'm going to return from the handler().  is there a way to get the
 logging phase to log the status that the user-agent got rather than the
 return value of the handler()?
 
 here's my small script which illustrates what i'm trying to do:
 
   sub mod_perl_error
   {
   # a request object is the first argument
   # in handler, return mod_perl_error($r);
   $_[0]-status( SERVER_ERROR );
   $_[0]-content_type('text/html');
   $_[0]-send_http_header;
   
   $_[0]-print("There was an oopsie.");
   
   return DONE; # the log ends up with status 200  
   }

argh, because Apache.xs:send_http_header does this:
r-status = 200; /* XXX, why??? */

i think this was to deal with Apache::cgi_header_out() (used by CGI.pm).
if it modified $r-status, then Apache::send_cgi_header() would call
$r-send_http_header and Apache would also call send_http_header() because
mod_perl returned that status, indicating error or redirect.
with this patch, you don't need to touch $r-status and a 500 will be
properly logged.

Index: src/modules/perl/Apache.xs
===
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.111
diff -u -r1.111 Apache.xs
--- src/modules/perl/Apache.xs  2000/09/27 23:51:33 1.111
+++ src/modules/perl/Apache.xs  2000/09/28 16:11:02
@@ -929,7 +929,6 @@
 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
 
Index: Apache/Apache.pm
===
RCS file: /home/cvs/modperl/Apache/Apache.pm,v
retrieving revision 1.53
diff -u -r1.53 Apache.pm
--- Apache/Apache.pm2000/08/31 05:49:05 1.53
+++ Apache/Apache.pm2000/09/28 16:11:12
@@ -180,7 +180,8 @@
else {
$not_sent = 1;
}
-   $r-send_http_header if $not_sent;
+   $r-send_http_header if
+  $not_sent and $r-status == 200;
$r-print($headers); #send rest of buffer, without stripping newlines!!!
last;
}




Logging real HTTP status

2000-09-13 Thread brian d foy


let's suppose that i want to change the HTTP status to be something other
than i'm going to return from the handler().  is there a way to get the
logging phase to log the status that the user-agent got rather than the
return value of the handler()?

here's my small script which illustrates what i'm trying to do:

sub mod_perl_error
{
# a request object is the first argument
# in handler, return mod_perl_error($r);
$_[0]-status( SERVER_ERROR );
$_[0]-content_type('text/html');
$_[0]-send_http_header;

$_[0]-print("There was an oopsie.");

return DONE; # the log ends up with status 200  
}


--
brian d foy  [EMAIL PROTECTED]
Director of Technology, Smith Renaud, Inc.
875 Avenue of the Americas, 2510, New York, NY  10001
V: (212) 239-8985