Hey there. I have a small problem with sockets. The code is really
simple, but it still fails.
The problem is I am accessing a .rar file (for those who don't know
it's an archive, like .zip) through fsockopen and I'm only getting the
headers... The file is not coming.
# Open the host
$fp = fsockopen($url['host'], 80, $errno, $errstr, 30);
# Ask for the file. $method is GET and $GET is the path and filename
of the file (files/eye.rar).
$out = $method.' '.$GET.' HTTP/1.0
';
# I also send HOST header properly
# and user agent
# Send a blank line to indicate end of headers
$out .= '
';
fwrite($fp, $out);
$buffer = fread($fp, 4000000);
print $buffer;
die;
The result is:
HTTP/1.1 200 OK
Date: Mon, 11 Feb 2008 14:25:48 GMT
Connection: close
Content-Type: application/octet-stream
Accept-Ranges: bytes
Content-Disposition: Attachment; filename=eye.ra r
Content-Length: 466159
I should have gotten the headers + a part of the file. Why didn't I?
Can anyone help me, please?
simple, but it still fails.
The problem is I am accessing a .rar file (for those who don't know
it's an archive, like .zip) through fsockopen and I'm only getting the
headers... The file is not coming.
# Open the host
$fp = fsockopen($url['host'], 80, $errno, $errstr, 30);
# Ask for the file. $method is GET and $GET is the path and filename
of the file (files/eye.rar).
$out = $method.' '.$GET.' HTTP/1.0
';
# I also send HOST header properly
# and user agent
# Send a blank line to indicate end of headers
$out .= '
';
fwrite($fp, $out);
$buffer = fread($fp, 4000000);
print $buffer;
die;
The result is:
HTTP/1.1 200 OK
Date: Mon, 11 Feb 2008 14:25:48 GMT
Connection: close
Content-Type: application/octet-stream
Accept-Ranges: bytes
Content-Disposition: Attachment; filename=eye.ra r
Content-Length: 466159
I should have gotten the headers + a part of the file. Why didn't I?
Can anyone help me, please?