|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46896 stream_get_meta_data() does not fill header list
Submitted: 2008-12-18 10:22 UTC Modified: 2009-01-23 15:52 UTC
From: christian dot lefebvre at atosorigin dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.8 OS: linux
Private report: No CVE-ID: None
 [2008-12-18 10:22 UTC] christian dot lefebvre at atosorigin dot com
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("", 'r');
$meta = stream_get_meta_data($src);
$data= fread($src, 500);
echo $data."\n\n";

this one works (just call fread before get_meta) :

$src = fopen("", 'r');
$data= fread($src, 500);
$meta = stream_get_meta_data($src);
echo $data."\n\n";

Expected result:
array(10) {
  array(2) {
    array(8) {
      string(15) "HTTP/1.1 200 OK"
      string(35) "Date: Thu, 18 Dec 2008 10:15:19 GMT"
      string(14) "Server: Apache"
      [3]=> ....

Actual result:
array(10) {
  array(2) {
    array(0) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-18 11:37 UTC]
See also bug #45092 (quite likely related)
 [2008-12-18 20:31 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

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.
 [2008-12-18 20:44 UTC] christian dot lefebvre at atosorigin dot com
Sorry, but in the given example, the call to the function returns a meta_data element with an EMPTY header sub-array despite the remote server do returns headers.
The expected result is an array with header lines, and that's done only if you use fread BEFORE.
 [2009-01-23 15:52 UTC] christian dot lefebvre at atosorigin dot com
I disagree with the Bogus status.
As I have a workaround, this problem has a low priority for me, but I consider it as a regression (see preceding comment).
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Aug 04 05:13:43 2020 UTC