cvs: php4 /ext/standard head.c
| From: | Sascha Schumann | Date: | Fri, 27 Oct 2000 09:43:06 +0000 |
| Subject: | cvs: php4 /ext/standard head.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2286@lists.php.net to get a copy of this message | ||
sas Fri Oct 27 02:43:06 2000 EDT
Modified files:
/php4/ext/standard head.c
Log:
Allow users to specify whether they want to replace existing header fields.
Index: php4/ext/standard/head.c
diff -u php4/ext/standard/head.c:1.35 php4/ext/standard/head.c:1.36
--- php4/ext/standard/head.c:1.35 Mon Jun 5 16:21:57 2000
+++ php4/ext/standard/head.c Fri Oct 27 02:43:06 2000
@@ -15,7 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: head.c,v 1.35 2000/06/05 23:21:57 sas Exp $ */
+/* $Id: head.c,v 1.36 2000/10/27 09:43:06 sas Exp $ */
#include <stdio.h>
#include "php.h"
@@ -59,17 +59,25 @@
/* Implementation of the language Header() function */
-/* {{{ proto void header(string header)
+/* {{{ proto void header(string header[, bool replace])
Send a raw HTTP header */
PHP_FUNCTION(Header)
{
- pval **arg1;
-
- if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
+ pval **arg1, **arg2;
+ zend_bool replace = 1;
+
+ if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2
+ || zend_get_parameters_ex(ZEND_NUM_ARGS(), &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
+ }
+ switch (ZEND_NUM_ARGS()) {
+ case 2:
+ convert_to_boolean_ex(arg2);
+ replace = Z_BVAL_PP(arg2);
+ case 1:
+ convert_to_string_ex(arg1);
}
- convert_to_string_ex(arg1);
- sapi_add_header(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1);
+ sapi_add_header_ex(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1, replace);
}
/* }}} */