cURL, using CURLOPT_HEADERFUNCTION problem

Найч

Алгоритмик :-)
cURL, using CURLOPT_HEADERFUNCTION problem

Hi!

Проблема в следующем. Отправляю HEAD запрос (CURLOPT_NOBODY == 1) и хочу при помощи установленной функции (CURLOPT_HEADERFUNCTION) читать заголовки. Вывов указанной функции происходит только 1 раз на первый заголовок
Код:
HTTP/1.1 200 OK
Хотя ожидаемый результат - вызов ее на каждый полученный заголовок. Без использования CURLOPT_HEADERFUNCTION сервер возвращает всю пачку заголовков.

По теме нашел старый баг с теми же признаками http://bugs.php.net/bug.php?id=11901, однако я пользую php 5.1.2

Reproduce code (from http://ua2.php.net/manual/en/ref.curl.php#31024):
PHP:
function read_header($ch, $header)
{
   print_r ($header);
}

function get($remote_file)
{
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $remote_file);
   curl_setopt($ch, CURLOPT_HEADER, 1);
   curl_setopt($ch, CURLOPT_NOBODY, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');

   $headers = curl_exec ($ch);
   curl_close ($ch);
}

get('http://www.google.com.ua/');
Вариант без CURLOPT_NOBODY возвращает тот же результат. Ошибка в пользовании или баг?
Apache/2.0.53 (Unix) PHP/5.1.2
 

tony2001

TeaM PHPClub
PHP:
function read_header($ch, $header) 
{ 
   print_r ($header); 
}
CURLOPT_HEADERFUNCTION
The name of a callback function where the callback function takes two parameters. The first is the CURL resource, the second is a string with the header data to be written. Using this callback function, it becomes your responsibility to write the header data. Return the number of bytes written.
 
Сверху