Re: Apache::Registry and 304 status code in log file

1999-12-13 Thread Doug MacEachern

see Apache::RedirectLogFix

On Thu, 11 Nov 1999, Bill Moseley wrote:

> In an Apache::Registry script I'm print()ing
> 
>Status: 304 Not Modified
> 
> when the client sends an If-Modified-Since: header.
> 
> The 304 error is returned to the client properly, but the log file shows a
> 200 status.  Can I make Apache log the access as a 304 with my
> Apache::Registry script?  The same script runs someplace else as mod_cgi.
> 
> Thanks,
> 
> BTW -- In perldoc Apache::Registry
> 
> I'm sure this is known, but...
> 
>  
>   SetHandler perl-script
>   PerlHandler Apache::Registry
>   Options ExecCGI
>   ...
> <-- shouldn't this be 
> 
> 
> 
> 
> Bill Moseley
> mailto:[EMAIL PROTECTED]
> 



Re: Apache::Registry and 304 status code in log file

1999-11-11 Thread darren chamberlain

Bill Moseley ([EMAIL PROTECTED]) wrote:
> In an Apache::Registry script I'm print()ing
> 
>Status: 304 Not Modified
> 
> when the client sends an If-Modified-Since: header.
> 
> The 304 error is returned to the client properly, but the log file shows a
> 200 status.  Can I make Apache log the access as a 304 with my
> Apache::Registry script?  The same script runs someplace else as mod_cgi.

Be sure to return HTTP_NOT_MODIFIED at the end of your script, and not OK.
Also, be sure to explicitly import HTTP_NOT_MODIFIED in your use
Apache::Constants statement, or import the ':http' tag.

darren



Apache::Registry and 304 status code in log file

1999-11-11 Thread Bill Moseley

In an Apache::Registry script I'm print()ing

   Status: 304 Not Modified

when the client sends an If-Modified-Since: header.

The 304 error is returned to the client properly, but the log file shows a
200 status.  Can I make Apache log the access as a 304 with my
Apache::Registry script?  The same script runs someplace else as mod_cgi.

Thanks,

BTW -- In perldoc Apache::Registry

I'm sure this is known, but...

 
  SetHandler perl-script
  PerlHandler Apache::Registry
  Options ExecCGI
  ...
<-- shouldn't this be 




Bill Moseley
mailto:[EMAIL PROTECTED]



Re: Apache::Registry and 304 status code in log file

1999-01-16 Thread Bill Moseley

I've got a program that I want to run under Apache::Registry, or mod_cgi if
mod_perl is not installed.

The problem, some of you may remember, is that even though I was sending 

   Status: 304 Not Modified

to the client, my log file was showing a return of 200.  I've got
PerlSendHeader enabled.  So, I was trying to find a way to get the access
log to show the 304 response instead of 200.

The solution was to exit with Apache::exit( HTTP_NOT_MODIFIED ) as
suggested by Darren Chamberlain.

To make this run where mod_perl is not installed, I had to do some ugly and
clumsy coding (which I welcome a better solution).  Remember, I'm trying to
get this code to work under mod_cgi or mod_perl.

BEGIN {
eval "use Apache";
eval "use Apache::Constants qw/OK HTTP_NOT_MODIFIED/;";
if(  $@  ) {
eval "sub OK { 0; }"; die "$@" if $@;
eval "sub HTTP_NOT_MODIFIED { 0; }"; die "$@" if $@;
}
}

Then in my 304 generating routine I can call exit_program(1) when I want to
generate the 304 in the access log file.

sub exit_program {
my $return_code = ( shift ) ? HTTP_NOT_MODIFIED : OK;

( ($ENV{GATEWAY_INTERFACE} &&
   $ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/ )
   || $ENV{MOD_PERL} )

? Apache::exit( $return_code )
: exit;
}

Now this gets the 304 in my access log file, but it also has two side
effects that I'm trying to understand:

1) When calling Apache::exit( HTTP_NOT_MODIFIED ) Apache is creating double
headers.  I know I read about this some place, but I can't seem to find it
now.

Here's what's being sent:

HTTP/1.1 304 (Not Modified) Not Modified
Connection: close
Date: Thu, 18 Nov 1999 18:35:29 GMT
Server: Apache/1.3.9 (Unix) mod_perl/1.21
Content-Type: text/plain
Client-Date: Thu, 18 Nov 1999 18:35:15 GMT
Client-Peer: 169.229.32.30:3029

HTTP/1.1 304 Not Modified
Date: Thu, 18 Nov 1999 18:35:29 GMT
Server: Apache/1.3.9 (Unix) mod_perl/1.21
Connection: close

I get the headers I'd expect (not duplicated) if I call Apache::exit( OK ),
even when sending Status: 304 Not Modified.

2) Now when exiting via Apache::exit( HTTP_NOT_MODIFIED ) I get this in my
server error log:

[Thu Nov 18 10:35:29 1999] [error] 304

I wasn't expecting to see that, I guess.  Requesting an image, for example,
that returns a 304 error doesn't place that message in the log file.

Thanks,


Bill Moseley
mailto:[EMAIL PROTECTED]