473,485 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Proxying a FLV file

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
Mar 19 '08 #1
4 2611
ad*************@gmail.com wrote:
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/
Mar 19 '08 #2
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)
Mar 19 '08 #3
On Wed, 19 Mar 2008 21:14:57 +0100, ad*************@gmail.com
<ad*************@gmail.comwrote:
>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
Mar 19 '08 #4
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.
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.
Mar 19 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3908
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
5
5429
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
7
3512
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
3
26236
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
0
3907
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
4280
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
6
11627
by: Tim Arnold | last post by:
Hi, I'm using ElementTree which is wonderful. I have a need now to write out an XML file with these two headers: <?xml version="1.0" encoding="UTF-8" ?> <?NLS TYPE="org.eclipse.help.toc"?> My...
3
1241
by: Jeff Dege | last post by:
We have an app that is written in C#/ASP.NET 2.0, and hosted on IIS. Or rather, it's mostly written in ASP.NET, but parts of it are client- side javascript, pulling data from an Apache webserver...
2
1153
by: Martin Marcher | last post by:
Hello, more a recipe question. I'm working on a proxy that will download a file for a client. The thing that doesn't yield problems is: Alice (Client) Bob (Client) Sam (Server) 1 Alice...
0
7116
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6825
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5418
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4857
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1376
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
247
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.