ID: 48733
Updated by: [email protected]
Reported By: sta at netimage dot dk
-Status: Open
+Status: Assigned
Bug Type: cURL related
Operating System: FreeBSD 7.1
PHP Version: 5.2.10
-Assigned To:
+Assigned To: iliaa
Previous Comments:
------------------------------------------------------------------------
[2009-06-30 10:05:30] sta at netimage dot dk
Description:
------------
I have a script that temporarily stores the headers in a file created
by $fp_header = tmpfile().
It worked perfectly until upgrading from 5.2.9.
Now curl_setopt($ch, CURLOPT_WRITEHEADER, $fp_header)
triggers a warning:
Warning: curl_setopt(): the provided file handle is not writable in
/curl.php on line x
Reproduce code:
---------------
<?php
ini_set('display_errors',1); error_reporting(E_ALL | E_STRICT);
$ch = curl_init('http://dk.php.net/');
if ( ! ($fp_header = tmpfile())) { die('File not created'); }
curl_setopt($ch, CURLOPT_WRITEHEADER, $fp_header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); echo "HTTP
$http_code\n";
curl_close($ch);
echo "Headers ===>\n";
rewind($fp_header); echo stream_get_contents($fp_header);
echo "<=== Headers\n";
rewind($fp_header); ftruncate($fp_header, 0);
fwrite($fp_header, "The file is writeable\n");
echo "My test ===>\n";
rewind($fp_header); echo stream_get_contents($fp_header);
echo "<=== My test\n";
fclose($fp_header);
Expected result:
----------------
Output from PHP 5.2.9 (run from command line):
HTTP 200
Headers ===>
HTTP/1.1 200 OK
Date: Tue, 30 Jun 2009 09:51:08 GMT
Server: Apache/2.2.9 (FreeBSD) DAV/2 PHP/5.2.8 with Suhosin-Patch
X-Powered-By: PHP/5.2.8
Last-Modified: Tue, 30 Jun 2009 10:37:51 GMT
Content-language: en
Set-Cookie: COUNTRY=DNK%2C193.162.142.106; expires=Tue, 07-Jul-2009
09:51:08 GMT; path=/; domain=.php.net
X-PHP-QUESTION: I wonder if anyone will ever notice this
Transfer-Encoding: chunked
Content-Type: text/html;charset=utf-8
<=== Headers
My test ===>
The file is writeable
<=== My test
Actual result:
--------------
Output from PHP 5.2.10 (run from command line):
PHP Warning: curl_setopt(): the provided file handle is not writable
in /curl.php on line 5
Warning: curl_setopt(): the provided file handle is not writable in
/curl.php on line 5
HTTP 200
Headers ===>
<=== Headers
My test ===>
The file is writeable
<=== My test
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48733&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.