cvs: php4 /main SAPI.c
| From: | Sander Roobol | Date: | Tue, 18 Jun 2002 10:16:36 +0000 |
| Subject: | cvs: php4 /main SAPI.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-12399@lists.php.net to get a copy of this message | ||
sander Tue Jun 18 06:16:36 2002 EDT
Modified files:
/php4/main SAPI.c
Log:
Patch by Michael Sisolak <msisolak@yahoo.com> to make header() honor the
replace parameter. Closes #16458.
Index: php4/main/SAPI.c
diff -u php4/main/SAPI.c:1.129 php4/main/SAPI.c:1.130
--- php4/main/SAPI.c:1.129 Mon Jan 14 08:36:54 2002
+++ php4/main/SAPI.c Tue Jun 18 06:16:36 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: SAPI.c,v 1.129 2002/01/14 13:36:54 sesser Exp $ */
+/* $Id: SAPI.c,v 1.130 2002/06/18 10:16:36 sander Exp $ */
#include <ctype.h>
#include <sys/stat.h>
@@ -385,6 +385,11 @@
return code;
}
+static int sapi_find_matching_header(void *element1, void *element2)
+{
+ return strncasecmp(((sapi_header_struct*)element1)->header, (char*)element2,
strlen((char*)element2)) == 0;
+}
+
/* This function expects a *duplicated* string, that was previously emalloc()'d.
* Pointers sent to this functions will be automatically freed by the framework.
*/
@@ -551,6 +556,19 @@
zend_llist_clean(&SG(sapi_headers).headers);
}
if (retval & SAPI_HEADER_ADD) {
+ /* in replace mode first remove the header if it already exists in the headers llist */
+ if (replace) {
+ colon_offset = strchr(header_line, ':');
+ if (colon_offset) {
+ char sav;
+ colon_offset++;
+ sav = *colon_offset;
+ *colon_offset = 0;
+ zend_llist_del_element(&SG(sapi_headers).headers, header_line, (int(*)(void*,
void*))sapi_find_matching_header);
+ *colon_offset = sav;
+ }
+ }
+
zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_header);
}
if (free_header) {