I don't know how to write a better title. Feel free to edit. Somehow I didn't find anything on this:
I have a cURL request from PHP which returns a quicktime file. This works fine if I want to output the stream in the browser's window. But I want to send it as it were a real file. How can I pass the headers and set it to the script's output, without the need of storing everything in a variable.
The script looks like this:
if (preg_match('/^[\w\d-]{36}$/',$key)) {
// create url
$url = $remote . $key;
// init cURL request
$ch = curl_init($url);
// set options
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
if (null !== $username) {
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
}
// execute request
curl_exec($ch);
// close
curl_close($ch);
}
I can see the header and content like this, so the request itself is working fine:
HTTP/1.1 200 OK X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2 Java/Oracle Corporation/1.7) Server: GlassFish Server Open Source Edition 3.1.2 Content-Type: video/quicktime Transfer-Encoding: chunked