diff options
author | Ferenc Kovacs <tyrael@php.net> | 2015-03-30 01:08:39 +0200 |
---|---|---|
committer | Ferenc Kovacs <tyrael@php.net> | 2015-03-30 01:09:07 +0200 |
commit | fd01b47b8e07ebfbd39627c4a8926d40c48f93d3 (patch) | |
tree | 6fb710332b7d64977aed3941a8fafd04710bfa97 /ext/standard/tests/url | |
parent | 6a8ab3d7c6e24b2294099647ba0ebf2addf16bd0 (diff) | |
download | php-git-fd01b47b8e07ebfbd39627c4a8926d40c48f93d3.tar.gz |
Implemented FR #55716 - Add an option to pass a custom stream context
Diffstat (limited to 'ext/standard/tests/url')
-rw-r--r-- | ext/standard/tests/url/get_headers_error_001.phpt | 7 | ||||
-rw-r--r-- | ext/standard/tests/url/get_headers_error_003.phpt | 31 |
2 files changed, 35 insertions, 3 deletions
diff --git a/ext/standard/tests/url/get_headers_error_001.phpt b/ext/standard/tests/url/get_headers_error_001.phpt index 8d5fd11f60..270c8350c0 100644 --- a/ext/standard/tests/url/get_headers_error_001.phpt +++ b/ext/standard/tests/url/get_headers_error_001.phpt @@ -5,7 +5,7 @@ June Henriksen <juneih@redpill-linpro.com> #PHPTestFest2009 Norway 2009-06-09 \o/ --FILE-- <?php -/* Prototype : proto array get_headers(string url[, int format]) +/* Prototype : proto array get_headers(string url[, int format[, resource $context]]) * Description: Fetches all the headers sent by the server in response to a HTTP request * Source code: ext/standard/url.c * Alias to functions: @@ -21,8 +21,9 @@ var_dump( get_headers() ); echo "\n-- Testing get_headers() function with more than expected no. of arguments --\n"; $url = 'string_val'; $format = 1; +$context = stream_context_get_default(); $extra_arg = 10; -var_dump( get_headers($url, $format, $extra_arg) ); +var_dump( get_headers($url, $format, $context, $extra_arg) ); echo "Done"; ?> @@ -36,7 +37,7 @@ NULL -- Testing get_headers() function with more than expected no. of arguments -- -Warning: get_headers() expects at most 2 parameters, 3 given in %s on line 19 +Warning: get_headers() expects at most 3 parameters, 4 given in %s on line 20 NULL Done diff --git a/ext/standard/tests/url/get_headers_error_003.phpt b/ext/standard/tests/url/get_headers_error_003.phpt new file mode 100644 index 0000000000..6c8878513c --- /dev/null +++ b/ext/standard/tests/url/get_headers_error_003.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test get_headers() function : test with context +--FILE-- +<?php + +include dirname(__FILE__)."/../../../../sapi/cli/tests/php_cli_server.inc"; +php_cli_server_start('header("X-Request-Method: ".$_SERVER["REQUEST_METHOD"]);'); + +$opts = array( + 'http' => array( + 'method' => 'HEAD' + ) +); + +$context = stream_context_create($opts); +$headers = get_headers("http://".PHP_CLI_SERVER_ADDRESS, 1, $context); +echo $headers["X-Request-Method"]."\n"; + +stream_context_set_default($opts); +$headers = get_headers("http://".PHP_CLI_SERVER_ADDRESS, 1); +echo $headers["X-Request-Method"]."\n"; + +echo "Done"; +?> +--EXPECTF-- +HEAD +HEAD +Done + + + |