Annotation of embedaddon/php/ext/curl/tests/curl_writeheader_callback.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test curl option CURLOPT_HEADERFUNCTION
! 3: --CREDITS--
! 4: Mathieu Kooiman <mathieuk@gmail.com>
! 5: Dutch UG, TestFest 2009, Utrecht
! 6: --DESCRIPTION--
! 7: 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.
! 8: --SKIPIF--
! 9: <?php
! 10: if (!extension_loaded("curl")) {
! 11: echo "skip - curl extension not available in this build";
! 12: }
! 13: if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
! 14: echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
! 15: }
! 16: ?>
! 17: --FILE--
! 18: <?php
! 19:
! 20: function 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();
! 29: curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
! 30: curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'curl_header_callback');
! 31: curl_setopt($ch, CURLOPT_URL, $host);
! 32: curl_exec($ch);
! 33: curl_close($ch);
! 34:
! 35: ?>
! 36: --EXPECTF--
! 37: HTTP/1.1 %d %s
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>