summaryrefslogtreecommitdiff
path: root/ext/standard/tests/url
diff options
context:
space:
mode:
authorFerenc Kovacs <tyrael@php.net>2015-10-08 10:23:24 +0200
committerFerenc Kovacs <tyrael@php.net>2015-10-08 10:23:24 +0200
commit1e66f1b9add70ecc3c5f1826cce930c968266bf8 (patch)
treeadc2c3762014333b43e732314bb8dc81169e9354 /ext/standard/tests/url
parent478e8d6b6d97e53c9e278ec783a2a4fa963df344 (diff)
parent0a10440cad5adf6c3d9b1eeb1e3e69f64ecd0d68 (diff)
downloadphp-git-1e66f1b9add70ecc3c5f1826cce930c968266bf8.tar.gz
Merge branch 'pr-1204'
* pr-1204: no need for default value allow passing null as the third param 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.phpt7
-rw-r--r--ext/standard/tests/url/get_headers_error_003.phpt31
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
+
+
+