1--TEST-- 2Test curl option CURLOPT_HEADERFUNCTION 3--CREDITS-- 4Mathieu Kooiman <mathieuk@gmail.com> 5Dutch UG, TestFest 2009, Utrecht 6--DESCRIPTION-- 7Hit the host and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers might return different sets of headers. Just test for HTTP/1.1 200 OK. 8--SKIPIF-- 9<?php include 'skipif.inc'; ?> 10--FILE-- 11<?php 12 13function curl_header_callback($curl_handle, $data) 14{ 15 if (strtolower(substr($data,0, 4)) == 'http') 16 echo $data; 17} 18 19include 'server.inc'; 20$host = curl_cli_server_start(); 21 22$ch = curl_init(); 23curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 24curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'curl_header_callback'); 25curl_setopt($ch, CURLOPT_URL, $host); 26curl_exec($ch); 27curl_close($ch); 28 29?> 30--EXPECTF-- 31HTTP/1.1 %d %s 32