Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:19 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.