Bug #15038: replace parameter of Header() function doesn't work in Apache module
| From: | phpman at toowards dot com | Date: | Tue, 15 Jan 2002 05:46:04 +0000 |
| Subject: | Bug #15038: replace parameter of Header() function doesn't work in Apache module | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-77092@lists.php.net to get a copy of this message | ||
From: phpman@toowards.com
Operating system: linux
PHP version: 4.1.0
PHP Bug Type: Apache related
Bug description: replace parameter of Header() function doesn't work in Apache module
The code (from the Header() manual page)
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate");
// HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// HTTP/1.0
only outputs a single "Cache-control" - the second one.
It seems to me that the "replace" flag of sapi_header was never being
checked.
I've written a fix for this though as shown below. I hope this is right,
and that it is useful to someone :-)
diff -aur php-4.1.0/sapi/apache/mod_php4.c
php-4.1.0-tt/sapi/apache/mod_php4.c
--- php-4.1.0/sapi/apache/mod_php4.c Mon Sep 17 01:49:55 2001
+++ php-4.1.0-tt/sapi/apache/mod_php4.c Tue Jan 15 16:15:28 2002
@@ -206,8 +206,10 @@
r->content_type = pstrdup(r->pool, header_content);
} else if (!strcasecmp(header_name, "Set-Cookie")) {
table_add(r->headers_out, header_name, header_content);
- } else {
+ } else if ( sapi_header->replace ) {
table_set(r->headers_out, header_name, header_content);
+ } else {
+ table_add(r->headers_out, header_name, header_content);
}
*p = ':'; /* a well behaved header handler shouldn't change its
original arguments */
--
Edit bug report at: http://bugs.php.net/?id=15038&edit=1