diff options
author | Arnaud Le Blanc <lbarnaud@php.net> | 2008-11-13 10:14:04 +0000 |
---|---|---|
committer | Arnaud Le Blanc <lbarnaud@php.net> | 2008-11-13 10:14:04 +0000 |
commit | 8c4151ad72b6c5a82b341aaf59d2c31521ca4341 (patch) | |
tree | ccc7c01da54fd7f7a02d03d7017e78a359aa254e /sapi/cgi | |
parent | 06119f4748066e61163764bbb31d1db4b21b6d07 (diff) | |
download | php-git-8c4151ad72b6c5a82b341aaf59d2c31521ca4341.tar.gz |
Added header_remove() (chsc at peytz dotdk, Arnaud)
[DOC] proto void header_remove([string header_name])
Removes an HTTP header previously set using header()
The header_name parameter is optionnal, all headers are
removed if it is not set
[SAPIs] The header_handler callback in sapi_module_struct has
been changed, it now take a new argument.
When it is set to SAPI_HEADER_DELETE, sapi_header->header is
the name of an header, header_handler has to delete it.
When it is set to SAPI_HEADER_DELETE_ALL, header_handler has
to delete all headers.
When sapi_header_op_enum is SAPI_HEADER_ADD or _REPLACE,
sapi_header->header is in the form "Name: value", header_handler
has to add or replace the given header.
In all cases, header_handler must not free sapi_header or
sapi_header->header. SAPI_HEADER_ADD must be returned if the
header has been added or replaced, or 0 in other cases.
Diffstat (limited to 'sapi/cgi')
-rw-r--r-- | sapi/cgi/tests/011.phpt | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/sapi/cgi/tests/011.phpt b/sapi/cgi/tests/011.phpt new file mode 100644 index 0000000000..177df021a6 --- /dev/null +++ b/sapi/cgi/tests/011.phpt @@ -0,0 +1,165 @@ +--TEST-- +header_remove() +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +include "include.inc"; + +$php = get_cgi_path(); +reset_env_vars(); + +$f = tempnam(sys_get_temp_dir(), 'cgitest'); + +function test($script) { + file_put_contents($GLOBALS['f'], $script); + $cmd = escapeshellcmd($GLOBALS['php']); + $cmd .= ' -n -dreport_zend_debug=0 -dhtml_errors=0 ' . escapeshellarg($GLOBALS['f']); + echo "----------\n"; + echo rtrim($script) . "\n"; + echo "----------\n"; + passthru($cmd); +} + +test('<?php ?>'); +test('<?php header_remove(); ?>'); +test('<?php header_remove("X-Foo"); ?>'); +test('<?php +header("X-Foo: Bar"); +?>'); +test('<?php +header("X-Foo: Bar"); +header("X-Bar: Baz"); +header_remove("X-Foo"); +?>'); +test('<?php +header("X-Foo: Bar"); +header_remove("X-Foo: Bar"); +?>'); +test('<?php +header("X-Foo: Bar"); +header_remove("X-Foo:"); +?>'); +test('<?php +header("X-Foo: Bar"); +header_remove(); +?>'); +test('<?php +header_remove(""); +?>'); +test('<?php +header_remove(":"); +?>'); +test('<?php +header("X-Foo: Bar"); +echo "flush\n"; +flush(); +header_remove("X-Foo"); +?>'); + +@unlink($f); +?> +--EXPECTF-- +---------- +<?php ?> +---------- +X-Powered-By: PHP/%s +Content-type: text/html + +---------- +<?php header_remove(); ?> +---------- +Content-type: text/html + +---------- +<?php header_remove("X-Foo"); ?> +---------- +X-Powered-By: PHP/%s +Content-type: text/html + +---------- +<?php +header("X-Foo: Bar"); +?> +---------- +X-Powered-By: PHP/%s +X-Foo: Bar +Content-type: text/html + +---------- +<?php +header("X-Foo: Bar"); +header("X-Bar: Baz"); +header_remove("X-Foo"); +?> +---------- +X-Powered-By: PHP/%s +X-Bar: Baz +Content-type: text/html + +---------- +<?php +header("X-Foo: Bar"); +header_remove("X-Foo: Bar"); +?> +---------- +X-Powered-By: PHP/%s +X-Foo: Bar +Content-type: text/html + + +Warning: Header to delete may not contain colon. in %s on line 3 +---------- +<?php +header("X-Foo: Bar"); +header_remove("X-Foo:"); +?> +---------- +X-Powered-By: PHP/%s +X-Foo: Bar +Content-type: text/html + + +Warning: Header to delete may not contain colon. in %s on line 3 +---------- +<?php +header("X-Foo: Bar"); +header_remove(); +?> +---------- +Content-type: text/html + +---------- +<?php +header_remove(""); +?> +---------- +X-Powered-By: PHP/%s +Content-type: text/html + +---------- +<?php +header_remove(":"); +?> +---------- +X-Powered-By: PHP/%s +Content-type: text/html + + +Warning: Header to delete may not contain colon. in %s on line 2 +---------- +<?php +header("X-Foo: Bar"); +echo "flush\n"; +flush(); +header_remove("X-Foo"); +?> +---------- +X-Powered-By: PHP/%s +X-Foo: Bar +Content-type: text/html + +flush + +Warning: Cannot modify header information - headers already sent by (output started at %s:3) in %s on line 5 |