]> granicus.if.org Git - php/commitdiff
Allow users to specify whether they want to replace existing header fields.
authorSascha Schumann <sas@php.net>
Fri, 27 Oct 2000 09:43:06 +0000 (09:43 +0000)
committerSascha Schumann <sas@php.net>
Fri, 27 Oct 2000 09:43:06 +0000 (09:43 +0000)
ext/standard/head.c

index 72c457a21937ae98a14cde0f1c20130f2a9375dd..77169cca4b47fa6688d4ac52eb05d1f61f8fa2a4 100644 (file)
@@ -59,17 +59,25 @@ PHP_RINIT_FUNCTION(head)
 
 
 /* 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;
        }
-       convert_to_string_ex(arg1);
-       sapi_add_header(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1);
+       switch (ZEND_NUM_ARGS()) {
+               case 2:
+                       convert_to_boolean_ex(arg2);
+                       replace = Z_BVAL_PP(arg2);
+               case 1:
+                       convert_to_string_ex(arg1);
+       }
+       sapi_add_header_ex(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1, replace);
 }
 /* }}} */