HTTP HEAD not showing content-length
Hi,
I've got a file download script that is working perfectly when issued with a GET request. However when it is issued with a HEAD request it leaves the Content-Length header out, even though I explicitly set it.
I think I'm going insane. The HEAD request is needed to allow compatibility with a P2P service we want to support for our downloaders, but I feel I'm at an impass.
This is a small excert from the download script..
require_once($DOCUMENT_ROOT."includes/ff_files.class.php");
$file = new ff_file($f, "viewhash", false, $db_link);
if ($_SERVER['REQUEST_METHOD'] == 'HEAD') {
ob_start();
$filename = $file->location.$file->name;
$filesize = filesize($filename);
if ($file->version == 3)
$display_filename = $file->display_name;
else
$display_filename = $file->name;
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header("Content-Length: $filesize");
header('Content-Disposition: attachment; filename=' .basename($display_filename));
mysql_close($db_link);
ob_flush();
exit();
}
Here is the dump from a telnet session..
[root@xx ~]# telnet xxx.xxxxxx.com 80
Trying xxx.xxx.xx.x.
Connected to xxx.xxxxxx.com (x.x.x.x).
Escape character is '^]'.
HEAD /dl/f/05a5ce/b/3/h/051b83b0ea5a2af6/ HTTP/1.0
Host: xxx.xxxxxx.com
HTTP/1.1 200 OK
Date: Thu, 31 Aug 2006 02:14:45 GMT
Server: Apache/2.0.52 (CentOS)
X-Powered-By: PHP/5.1.4
Content-Description: File Transfer
Content-Disposition: attachment; filename=1234.1234.rar
Connection: close
Content-Type: application/force-download
Connection closed by foreign host.
Any opinions / fixes would be MOST welcome??....
thanks
|