1--TEST--
2Test curl option CURLOPT_HEADERFUNCTION
3--CREDITS--
4Mathieu Kooiman <mathieuk@gmail.com>
5Dutch UG, TestFest 2009, Utrecht
6--DESCRIPTION--
7Hit 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.
8--SKIPIF--
9<?php
10if (!extension_loaded("curl")) {
11	echo "skip - curl extension not available in this build";
12}
13if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
14	echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
15}
16?>
17--FILE--
18<?php
19
20function curl_header_callback($curl_handle, $data)
21{
22	if (strtolower(substr($data,0, 4)) == 'http')
23		echo $data;
24}
25
26$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
27
28$ch = curl_init();
29curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
30curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'curl_header_callback');
31curl_setopt($ch, CURLOPT_URL, $host);
32curl_exec($ch);
33curl_close($ch);
34
35?>
36--EXPECTF--
37HTTP/1.1 %d %s
38