Connecting Tech Pros Worldwide Forums | Help | Site Map

Proxying a FLV file

adam.waterfield@gmail.com
Guest
 
Posts: n/a
#1: Mar 19 '08
I have a script that 'proxys' a .flv file from a .htaccess protected
folder. The proxying script is being called by a Flash flv player in
the main webpage.

This script works wonderfully in Firefox and co, but not at all in
Internet Explorer.

Proxy Script minus all the authentication gubbins...

function getRemoteFileSize($url)
{
$parsed = parse_url($url);
$host = $parsed["host"];
$fp = @fsockopen($host, 80, $errno, $errstr, 20);
if(!$fp)return false;
else {
@fputs($fp, "HEAD $url HTTP/1.1\r\n");
@fputs($fp, "HOST: $host\r\n");
@fputs($fp, "Connection: close\r\n\r\n");
$headers = "";
while(!@feof($fp))$headers .= @fgets ($fp, 128);
}
@fclose ($fp);
$return = false;
$arr_headers = explode("\n", $headers);
foreach($arr_headers as $header) {
$s = "Content-Length: ";
if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s))
{
$return = trim(substr($header, strlen($s)));
break;
}
}
}

$proxyURL = $_GET['url'];
header('Content-type: video/x-flv');
header('Content-length: '.getRemoteFileSize($proxyURL));
$src = fopen($proxyURL, 'r');
$out = fopen('php://output', 'w');
stream_copy_to_stream($src, $out);
fclose($src);
fclose($out);

As I said, this works fine in FF but not IE. Could anyone make any
suggestions as to why this could be? Perhaps some Header issues?

TIA

Toby A Inkster
Guest
 
Posts: n/a
#2: Mar 19 '08

re: Proxying a FLV file


adam.waterfield@gmail.com wrote:
Quote:
I have a script that 'proxys' a .flv file from a .htaccess protected
folder. The proxying script is being called by a Flash flv player in the
main webpage.
>
This script works wonderfully in Firefox and co, but not at all in
Internet Explorer.
Try typing in the URL for the FLV via the proxy directly into each
browsers' address bars and saving the resulting files. Check the MD5 sum
of each and see if your script has introduced any differences between them.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 19:35.]

The Semantic Web
http://tobyinkster.co.uk/blog/2008/03/09/sw/
adam.waterfield@gmail.com
Guest
 
Posts: n/a
#3: Mar 19 '08

re: Proxying a FLV file


Try typing in the URL for the FLV via the proxy directly into each
Quote:
browsers' address bars and saving the resulting files. Check the MD5 sum
of each and see if your script has introduced any differences between them.
Thanks for your response.

I have tried manually calling the proxy script with a file in the url
string. IE throws an error box window saying "Internet Explorer cannot
download script.php from localhost" and "Internet Explorer was not
able to open this Internet site - the site is either unavailable or
cannot be found. Try again later."

It would seem that IE doesn't like what this script is returning, yet
Firefox does? Seems odd. My first thoughts are the headers are playing
up - but yet with it been fine in FF it is a bit strange.

I was considering sticking these files in a DB opposed to a .htaccess
protected folder, but I don't fancy sticking 1.7gb of flv's into a DB!
(Especially when I would have the same issue, probably)
Rik Wasmus
Guest
 
Posts: n/a
#4: Mar 19 '08

re: Proxying a FLV file


On Wed, 19 Mar 2008 21:14:57 +0100, adam.waterfield@gmail.com
<adam.waterfield@gmail.comwrote:
Quote:
Quote:
>Try typing in the URL for the FLV via the proxy directly into each
>browsers' address bars and saving the resulting files. Check the MD5 sum
>of each and see if your script has introduced any differences between
>them.
>
Thanks for your response.
>
I have tried manually calling the proxy script with a file in the url
string. IE throws an error box window saying "Internet Explorer cannot
download script.php from localhost" and "Internet Explorer was not
able to open this Internet site - the site is either unavailable or
cannot be found. Try again later."
>
It would seem that IE doesn't like what this script is returning, yet
Firefox does? Seems odd. My first thoughts are the headers are playing
up - but yet with it been fine in FF it is a bit strange.
>
I was considering sticking these files in a DB opposed to a .htaccess
protected folder, but I don't fancy sticking 1.7gb of flv's into a DB!
(Especially when I would have the same issue, probably)
I could very well imagine your 'getRemoteFileSize' function fails (no HEAD
allowed for instance), resulting in incorrect headers, which FF tries to
ignore for you but MSIE barfs over. Check wether there's a valid return
from that function, and only then include a Content-Length header.

It would be somewhat simpler to determine if you could give us the result
of the exact headers being sent by your script.
--
Rik Wasmus
adam.waterfield@gmail.com
Guest
 
Posts: n/a
#5: Mar 19 '08

re: Proxying a FLV file


I could very well imagine your 'getRemoteFileSize' function fails (no HEAD
Quote:
allowed for instance), resulting in incorrect headers, which FF tries to
ignore for you but MSIE barfs over. Check wether there's a valid return
from that function, and only then include a Content-Length header.
Thank you Rik. I disabled the said function and it works perfectly. I
only wish I had thought of that before, this has been frustrating me
for many hours.

Thanks for your all help guys - once again this newsgroup has been
more than helpful.
Closed Thread