php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23759 PHP doesn't preserve subrequest status
Submitted: 2003-05-22 15:04 UTC Modified: 2003-05-22 21:43 UTC
From: jaboydjr at netwalk dot com Assigned: iliaa (profile)
Status: Closed Package: Apache2 related
PHP Version: 4.3.2RC4 OS: Linux 2.4.20
Private report: No CVE-ID: None
 [2003-05-22 15:04 UTC] jaboydjr at netwalk dot com
I attempted to use PHP for "branding" Apache2 error documents, and noticed
that it always returns status 200.  In order for PHP to work correctly in
this situation, it must return the status it is given.  This is especially
important for 401 status codes, since a browser must receive the 401 code
in order to know to present an authorization dialogue to the user.

The attached patch works for me to fix this problem; consider it just a
workaround patch if you wish.  The patch simply preserves non-zero request
codes passed in, and sets status HTTP_OK (=200) if 0 is passed in.
==============================================================================
--- php-4.3.2RC4-orig/sapi/apache2filter/sapi_apache2.c	2003-05-21 05:34:14.000000000 -0400
+++ php-4.3.2RC4/sapi/apache2filter/sapi_apache2.c	2003-05-22 15:43:09.000000000 -0400
@@ -376,7 +376,8 @@
 	const char *auth;
 	
 	PG(during_request_startup) = 0;
-	SG(sapi_headers).http_response_code = 200;
+	SG(sapi_headers).http_response_code = 
+		(!f->r->status ? HTTP_OK : f->r->status);
 	SG(request_info).content_type = apr_table_get(f->r->headers_in, "Content-Type");
 #undef safe_strdup
 #define safe_strdup(x) ((x)?strdup((x)):NULL)	
--- php-4.3.2RC4-orig/sapi/apache2handler/sapi_apache2.c	2003-05-21 05:34:14.000000000 -0400
+++ php-4.3.2RC4/sapi/apache2handler/sapi_apache2.c	2003-05-22 15:43:09.000000000 -0400
@@ -412,7 +412,7 @@
 	char *content_type;
 	const char *auth;
 
-	SG(sapi_headers).http_response_code = 200;
+	SG(sapi_headers).http_response_code = (!r->status ? HTTP_OK : r->status);
 	SG(request_info).content_type = apr_table_get(r->headers_in, "Content-Type");
 	SG(request_info).query_string = apr_pstrdup(r->pool, r->args);
 	SG(request_info).request_method = r->method;

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-22 17:43 UTC] sniper@php.net
Ilia promised to look into this.

 [2003-05-22 21:43 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 15:01:29 2024 UTC