note 96903 added to function.curl-setopt
| From: | anderseta at gmail dot com | Date: | Mon, 22 Mar 2010 10:48:12 +0000 |
| Subject: | note 96903 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167288@lists.php.net to get a copy of this message | ||
If you wish to find the size of the file you are streaming and use it as your header this is how:
<?php
function write_function($curl_resource, $string)
{
if(curl_getinfo($curl_resource, CURLINFO_CONTENT_TYPE) <= 1440)
{
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Description: File Transfer');
header("Content-Transfer-Encoding: binary");
header("Content-Type: ".curl_getinfo($curl_resource,
CURLINFO_CONTENT_TYPE)."");
header("Content-Length: ".curl_getinfo($curl_resource,
CURLINFO_CONTENT_LENGTH_DOWNLOAD)."");
}
print $string;
return mb_strlen($string, '8bit');
}
1440 is the the default number of bytes curl will call the write function (BUFFERSIZE does not
affect this, i actually think you can not change this value), so it means the headers are going to
be set only one time.
Writefunction must return the exact number of bytes of the string, so you can return a value with
mb_strlen.
?>
----
Server IP: 69.147.83.197
Probable Submitter: 189.11.104.92
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/96903
Del: integrated -- https://master.php.net/note/delete/96903/integrated
Del: useless -- https://master.php.net/note/delete/96903/useless
Del: bad code -- https://master.php.net/note/delete/96903/bad+code
Del: spam -- https://master.php.net/note/delete/96903/spam
Del: non-english -- https://master.php.net/note/delete/96903/non-english
Del: in docs -- https://master.php.net/note/delete/96903/in+docs
Del: other reasons-- https://master.php.net/note/delete/96903
Reject -- https://master.php.net/note/reject/96903
Search -- https://master.php.net/manage/user-notes.php