ID: 46896 Updated by: il...@php.net Reported By: christian dot lefebvre at atosorigin dot com -Status: Open +Status: Bogus Bug Type: cURL related Operating System: linux PHP Version: 5.2.8 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php The function always puts the headers into the wrapper_data element, this is consistent with PHP 5.1.2 and 5.3.0. The position of the fread() does not make any difference in the output. Previous Comments: ------------------------------------------------------------------------ [2008-12-18 11:37:27] j...@php.net See also bug #45092 (quite likely related) ------------------------------------------------------------------------ [2008-12-18 10:22:33] christian dot lefebvre at atosorigin dot com Description: ------------ With php 5.2.8 and curlwrapper option, after calling fopen() on a remote url, a call to stream_get_meta_data() returns an empty header list. If a call to fread() is inserted between fopen() and stream_get_meta_data(), the headers are presents. The problem appears during a migration from 5.0 without curl, to 5.2 with curl, so it seems curl related. Calling the test script via strace shows that the socket is opened, but there's no call to read() syscall before the stream_get_meta_data is called. The problem is not systematically reproduced (certainly due to response latencies), but appears very often. Reproduce code: --------------- this version fails : $src = fopen("http://www.perdu.com", 'r'); $meta = stream_get_meta_data($src); var_dump($meta); var_dump($http_response_header); $data= fread($src, 500); echo $data."\n\n"; this one works (just call fread before get_meta) : $src = fopen("http://www.perdu.com", 'r'); $data= fread($src, 500); $meta = stream_get_meta_data($src); var_dump($meta); var_dump($http_response_header); echo $data."\n\n"; Expected result: ---------------- array(10) { ["wrapper_data"]=> array(2) { ["headers"]=> array(8) { [0]=> string(15) "HTTP/1.1 200 OK" [1]=> string(35) "Date: Thu, 18 Dec 2008 10:15:19 GMT" [2]=> string(14) "Server: Apache" [3]=> .... Actual result: -------------- array(10) { ["wrapper_data"]=> array(2) { ["headers"]=> array(0) { } ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46896&edit=1