I run PHP via a simple-minded webserver which sets up some environment
variables and then calls my php scripts (which begin with a
"#!/usr/local/bin/php" line).  My scripts must handle all the headers,
including the HTTP status header.  My standard included file contains
"header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');", and other files may
emit a similar header with a different status code for redirection and
so forth.

Unfortunately, after upgrading to 4.3.2 I encountered two problems.
First, PHP was "helpfully" refusing to emit status headers for which the
status code was 200 even when explicity instructed to by the above
header() call.  Second, while my scripts would run correctly at the
command line, when run via a web server I was getting a 404 status and
the error message "No input file specified."

I have created a patch to work around the above problems; it is a hack,
but restores my desired functionality if I also set "cgi.rfc2616_headers
= 1" in php.ini.  PHP developers, if you're out there, please consider
backing out rev 1.195 of php4/sapi/cgi/cgi_main.c or adding a
configuration directive to disable its behaviour.  I'm not sure what the
correct solution for the "No input file specified" problem is; I'll try
to look into it more if I have some time next week, but this was my
first peek at PHP's source.

-Zak
--- sapi/cgi/cgi_main.c.orig    Mon May 26 19:21:08 2003
+++ sapi/cgi/cgi_main.c Fri Jun 13 13:11:58 2003
@@ -279,7 +279,7 @@
                rfc2616_headers = 0;
        }
 
-       if (SG(sapi_headers).http_response_code != 200) {
+       /* if (SG(sapi_headers).http_response_code != 200) */ {
                int len;
                
                if (rfc2616_headers) {
@@ -959,12 +959,14 @@
 #endif
        /* Make sure we detect we are a cgi - a bit redundancy here,
           but the default case is that we have to check only the first one. */
+       /*
        if (getenv("SERVER_SOFTWARE")
                || getenv("SERVER_NAME")
                || getenv("GATEWAY_INTERFACE")
                || getenv("REQUEST_METHOD")) {
                cgi = 1;
        }
+       */
 #if PHP_FASTCGI
        }
 #endif

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to