Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 30th, 2006, 09:39 PM
Registered User
 
Join Date: Aug 2006
Location: Brisbane, Qld, Australia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 26 Simple HTTP Module Not Showing In Sourc geomar BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 August 25th, 2007 12:39 PM
Maximum length of http Object mohan.karunanidhi Ajax 2 November 21st, 2006 06:11 AM
I am so in over my head AnnMarie Dreamweaver (all versions) 1 May 19th, 2005 02:19 PM
Can't get my head around - help. Mantis MySQL 2 February 23rd, 2005 12:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.