tony2001 Wed Feb 15 11:13:05 2006 UTC Modified files: (Branch: PHP_5_0) /php-src/sapi/apache mod_php5.c /php-src NEWS Log: MFH: fix #36400 (Custom 5xx error does not return correct HTTP response error code) http://cvs.php.net/viewcvs.cgi/php-src/sapi/apache/mod_php5.c?r1=1.10.2.4&r2=1.10.2.5&diff_format=u Index: php-src/sapi/apache/mod_php5.c diff -u php-src/sapi/apache/mod_php5.c:1.10.2.4 php-src/sapi/apache/mod_php5.c:1.10.2.5 --- php-src/sapi/apache/mod_php5.c:1.10.2.4 Mon Aug 1 08:12:42 2005 +++ php-src/sapi/apache/mod_php5.c Wed Feb 15 11:13:05 2006 @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php5.c,v 1.10.2.4 2005/08/01 08:12:42 dmitry Exp $ */ +/* $Id: mod_php5.c,v 1.10.2.5 2006/02/15 11:13:05 tony2001 Exp $ */ #include "php_apache_http.h" #include "http_conf_globals.h" @@ -67,6 +67,7 @@ /* ### these should be defined in mod_php5.h or somewhere else */ #define USE_PATH 1 #define IGNORE_URL 2 +#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST POSSIBLE STATUS DESCRIPTION") module MODULE_VAR_EXPORT php5_module; @@ -208,17 +209,35 @@ static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { request_rec *r = SG(server_context); + char *status_buf = NULL; + const char *sline = SG(sapi_headers).http_status_line; + int sline_len; if(r == NULL) { /* server_context is not here anymore */ return SAPI_HEADER_SEND_FAILED; } r->status = SG(sapi_headers).http_response_code; + + /* httpd requires that r->status_line is set to the first digit of + * the status-code: */ + if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ' && sline[12] == ' ') { + if ((sline_len - 9) > MAX_STATUS_LENGTH) { + status_buf = estrndup(sline + 9, MAX_STATUS_LENGTH); + } else { + status_buf = estrndup(sline + 9, sline_len - 9); + } + r->status_line = status_buf; + } + if(r->status==304) { send_error_response(r,0); } else { send_http_header(r); - } + } + if (status_buf) { + efree(status_buf); + } return SAPI_HEADER_SENT_SUCCESSFULLY; } /* }}} */ http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.1760.2.532&r2=1.1760.2.533&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.1760.2.532 php-src/NEWS:1.1760.2.533 --- php-src/NEWS:1.1760.2.532 Mon Feb 13 12:18:48 2006 +++ php-src/NEWS Wed Feb 15 11:13:05 2006 @@ -4,6 +4,8 @@ - Fixed an error in mysqli_fetch_fields (returned NULL instead of an array when row number > field_count). (Georg) - Renamed CachingRecursiveIterator to RecursiveCachingIterator. (Marcus) +- Fixed bug #36400 (Custom 5xx error does not return correct HTTP response + error code). (Tony) - Fixed bug #36303 (foreach on error_zval produces segfault). (Dmitry) - Fixed bug #36205 (Memory leaks on duplicate cookies). (Dmitry) - Fixed bug #36071 (Engine Crash related with 'clone'). (Dmitry)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php