summaryrefslogtreecommitdiff
path: root/ext/curl/tests/curl_writeheader_callback.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/curl/tests/curl_writeheader_callback.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/curl/tests/curl_writeheader_callback.phpt')
-rw-r--r--ext/curl/tests/curl_writeheader_callback.phpt37
1 files changed, 37 insertions, 0 deletions
diff --git a/ext/curl/tests/curl_writeheader_callback.phpt b/ext/curl/tests/curl_writeheader_callback.phpt
new file mode 100644
index 0000000..fa27363
--- /dev/null
+++ b/ext/curl/tests/curl_writeheader_callback.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test curl option CURLOPT_HEADERFUNCTION
+--CREDITS--
+Mathieu Kooiman <mathieuk@gmail.com>
+Dutch UG, TestFest 2009, Utrecht
+--DESCRIPTION--
+Hit the host identified by PHP_CURL_HTTP_REMOTE_SERVER and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers specified for PHP_CURL_HTTP_REMOTE_SERVER might return different sets of headers. Just test for HTTP/1.1 200 OK.
+--SKIPIF--
+<?php
+if (!extension_loaded("curl")) {
+ echo "skip - curl extension not available in this build";
+}
+if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
+ echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
+}
+?>
+--FILE--
+<?php
+
+function curl_header_callback($curl_handle, $data)
+{
+ if (strtolower(substr($data,0, 4)) == 'http')
+ echo $data;
+}
+
+$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'curl_header_callback');
+curl_setopt($ch, CURLOPT_URL, $host);
+curl_exec($ch);
+curl_close($ch);
+
+?>
+--EXPECTF--
+HTTP/1.1 %d %s