Re: [PHP4BETA] PHP4 confuses Apache/Errorpage settings

From: Date: Mon, 04 Oct 1999 14:23:58 +0000
Subject: Re: [PHP4BETA] PHP4 confuses Apache/Errorpage settings
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-5129@lists.php.net to get a copy of this message
On Mon, Oct 04, 1999 at 03:38:45PM +0200, Andreas Jung wrote: > Reply-To: > I'm running Apache 1.3.9 and PHP4Beta2 under Solaris. > > When I customize Apache with > Errorpage 404 /somepage.php3 > > all requests to pages that don't exist are logged in the > access.log with error code 200 instead of 404. As similar > behaviour occurs with error code 401. In this case an > authorization required header is send to the client and the > error page configured for error 401. > > Is there a way to get around this problem ? Please try the attached patch and let me know whether it fixes your problem. -- Regards, Sascha Schumann Consultant

Index: SAPI.c =================================================================== RCS file: /repository/php4/SAPI.c,v retrieving revision 1.31 diff -u -r1.31 SAPI.c --- SAPI.c 1999/09/16 23:18:15 1.31 +++ SAPI.c 1999/10/04 14:22:05 @@ -198,6 +198,20 @@ } } +static int sapi_extract_response_code(const char *header_line) +{ + int code = 200; + char *ptr; + + for (ptr = header_line; *ptr; ptr++) { + if (*ptr == ' ' && *(ptr + 1) != ' ') { + code = atoi(ptr + 1); + break; + } + } + + return code; +} /* This function expects a *duplicated* string, that was previously emalloc()'d. * Pointers sent to this functions will be automatically freed by the framework. @@ -221,6 +235,8 @@ /* Check the header for a few cases that we have special support for in SAPI */ if (header_line_len>=5 && !memcmp(header_line, "HTTP/", 5)) { + /* filter out the response code */ + SG(sapi_headers).http_response_code = sapi_extract_response_code(header_line); SG(sapi_headers).http_status_line = header_line; return SUCCESS; } else {
« previous php.version4 (#5129) next »