Win32 + ModPerl 2 + Apache 2 + NPH script = confusing header situation

[prev] [thread] [next] [Date index for 2005/03/04]

From: Formhandle
Subject: Win32 + ModPerl 2 + Apache 2 + NPH script = confusing header situation
Date: 05:24 on 04 Mar 2005
Hello,

I've gone through all documentation I can find as well as the mailing list 
archives (and Google!) and have not been able to resolve this.

I make use of a custom-coded access throttler in Perl which acts as a conduit 
for all incoming HTTP requests to my Apache web server.  The throttler is very 
THIN for the sake of performance and does not make use of outside libraries like 
CGI.pm, it is merely a proxy to the main site.  Because of this, the throttler 
requires me to manage and send out my own HTTP status codes, such as 401, 502, 
etc., rather than allow the Apache server to do so.  It is a NPH- script and I 
am trying to get it to work under mod_perl.  It works perfectly fine as a CGI 
(without mod_perl).

What happens when I run it under mod_perl is Apache (or mod_perl?) is not 
allowing the NPH- to act as an NPH- and presumes server-generated HTTP headers 
must be included with the response.  This causes the output to be sent as 
text/plain (server default set by DefaultType) and my own self-generated headers 
to get output with the content.

I've tried overriding this behavior with the various conf options as indicated 
by documentation but no matter how I configure things the output is the same. 
I've tried every configuration I could possibly use in regards to 
PerlSendHeaders On/Off (from mod_perl 1.0), PerlOptions +ParseHeaders, 
PerlOptions -Parseheaders, etc, and also leaving the settings out alltogether. 
The result is the same every time = server-generated headers overriding the 
self-generated headers in the script.

This ONLY is a problem if I send a status response before all other headers 
(such as content-type).  For example:

print "HTTP/1.1 502 Gateway Issue\n";
print "Content-type: text/html\n\n";
print "<html>Wait for the gateway...</html>";

Yes, I'm auto-flushing my output.

Setup:
Windows 2000 SP4
Apache 2.0.52
mod_perl 1.99_08-dev
Perl 5.6.1

I've noticed in the archives when others have brought this up is the common 
response is "turn PerlSendHeaders On" or set "PerlOptions +ParseHeaders" and 
this seems to fix things for those people.  For some reason, not for me.

        -- 
        Form <formhandle@xxxxxxxxxxxxx.xxx>

Fast Seduction 101 - http://www.fastseduction.com/
Class is now in session...


Win32 + ModPerl 2 + Apache 2 + NPH script = confusing header situation
Formhandle 05:24 on 04 Mar 2005

Generated at 08:54 on 14 Mar 2005 by mariachi v0.52