Bug #52820 [Ver->Asn]: curl doesn't write to php://temp or /memory

From: Date: Mon, 15 Nov 2010 05:08:29 +0000
Subject: Bug #52820 [Ver->Asn]: curl doesn't write to php://temp or /memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156033@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52820&edit=1

 ID:                 52820
 Updated by:         cataphract@php.net
 Reported by:        klawd+phpbugs at kamundo dot de
 Summary:            curl doesn't write to php://temp or /memory
-Status:             Verified
+Status:             Assigned
 Type:               Bug
 Package:            Streams related
 Operating System:   Ubuntu
 PHP Version:        5.3.3
-Assigned To:        
+Assigned To:        cataphract
 Block user comment: N

 New Comment:

I've identified the problem and I will commit a fix tomorrow.


Previous Comments:
------------------------------------------------------------------------
[2010-09-12 21:49:47] klawd+phpbugs at kamundo dot de

I didn't get the warning in my latest run. It could stem from the
missing open modes which would be weird but possible.

------------------------------------------------------------------------
[2010-09-12 21:37:43] cataphract@php.net

Right.

The problem was that I was testing on Windows, where this works.

I've just tested in Ubuntu, and indeed the string was empty there.
However, I didn't get the warning you've described.

------------------------------------------------------------------------
[2010-09-12 19:31:26] klawd+phpbugs at kamundo dot de

Fixed test script, now with example.com.

$handle=curl_init('http://example.com');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_STDERR, fopen('php://output', "w+"));
curl_exec($handle);
curl_setopt($handle, CURLOPT_STDERR, $output=fopen('php://temp',
"w+"));
curl_exec($handle);
rewind($output);
var_dump(stream_get_contents($output));

Please use var_dump. You will see that it's empty. There should be two
outputs:
- the one directly written to STDOUT
- one with string(n) and wrapped by var_dump's quotes
but the latter is empty:
string(0) ""

I tried both memory and temp

------------------------------------------------------------------------
[2010-09-12 13:37:48] cataphract@php.net

Anyway, this works here:

<?php
$handle=curl_init('http://www.google.com/');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_STDERR, $o = fopen('php://temp', "w+"));
curl_exec($handle);
rewind($o);
echo "output: ".stream_get_contents($o);

php://memory doesn't work because that stream cannot be cast into a
stdio FILE, which curl apparently requires.

------------------------------------------------------------------------
[2010-09-12 13:21:41] cataphract@php.net

Your description and your test script don't match. The first mentions
"php://memory", the script uses "php://temp".

Additionally, you don't specify open modes in the test script.

Seeing the source code, there's a small error in that persistent
resources are not accepted (ZEND_FETCH_RESOURCE2 should have been used),
but it should not cause the problem you're describing.

Please fix the problems with your bug report.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=52820


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52820&edit=1


Thread (8 messages)

« previous php.bugs (#156033) next »