Bug #43468 [Com]: Curl doesn't handle php://memory stream
| From: | Crackfairofficial at gmail dot com | Date: | Tue, 29 Dec 2020 10:20:57 +0000 |
| Subject: | Bug #43468 [Com]: Curl doesn't handle php://memory stream | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231296@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=43468&edit=1
ID: 43468
Comment by: Crackfairofficial at gmail dot com
Reported by: peter at petersmit dot eu
Summary: Curl doesn't handle php://memory stream
Status: No Feedback
Type: Bug
Package: cURL related
Operating System: Ubuntu Linux Gutsy Gibbon
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
Remarkable blog! Thank you for sharing this incredible piece.Fantastic items from you, man.
I've been aware of your stuff previous to and you are simply too excellent.
<a href=" https://crackmypc.com/minitool-power-data-recovery-9-0-crack/">minitool-power-data-recovery-9-0-crack</a>
Previous Comments:
------------------------------------------------------------------------
[2009-02-11 02:13:44] davirtavares at gmail dot com
The final workaround I currently use is setting both CURLOPT_WRITEFUNCTION and CURLOPT_READFUNCTION
options. So I can write and read using the memory stream, even being unsupported by CURL:
// open the memory stream (currently using "temp" but it should works with
"memory" stream as well):
$temp = fopen('php://temp', 'rb+');
function cb_curl_write($ch, $data) {
global $temp;
return fwrite($temp, $data);
}
function cb_curl_read($ch, $fd, $size) {
global $temp;
return fread($temp, $size);
}
// put some data into the stream:
// TODO
rewind($temp);
// get the content size of the stream
$input_stat = fstat($temp);
$input_size = $input_stat['size'];
$ch = curl_init('http://www.php.net/');
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILESIZE, $input_size);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'cb_curl_write');
curl_setopt($ch, CURLOPT_READFUNCTION, 'cb_curl_read');
curl_exec($ch);
curl_close($ch);
------------------------------------------------------------------------
[2009-01-29 02:14:06] davirtavares at gmail dot com
Well, I just discovered that I can use fstat to get the size of a stream (even memory ones).
Follows the test case:
$fi = fopen('php://temp', 'rb+');
// fill the $fi stream with some data
$input_stat = fstat($fi);
$input_size = $input_stat['size'];
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $fi);
curl_setopt($ch, CURLOPT_INFILESIZE, $input_size);
curl_exec($ch);
Davi
------------------------------------------------------------------------
[2009-01-29 00:06:27] davirtavares at gmail dot com
I got the same problem. I'm trying to submit data by PUT request and aparently memory streams
don't work for just a single CURL option:
curl_setopt($ch, CURLOPT_INFILESIZE, $input_size);
Aparently some servers don't like when you submit data w/o the content-size.
But... how to obtain the size of a memory stream?
Davi
------------------------------------------------------------------------
[2008-12-18 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2008-12-11 02:41:48] dan dot hitt at gmail dot com
I built again, and tried Peter's test again, and it failed again.
But note that with either the build from today or yesterday it
gives partial results for the wikipedia (it looks like it loses
the last 497 characters).
My configuration command is:
./configure --prefix=/home/danh/staging/php/2008_12_11_a
--with-curl=/home/danh/staging/curl/2008_09_12
dan
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=43468
--
Edit this bug report at https://bugs.php.net/bug.php?id=43468&edit=1