php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21496 Header weirdness
Submitted: 2003-01-07 12:55 UTC Modified: 2003-01-08 06:12 UTC
From: liz at xcalibur dot demon dot co dot uk Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.0 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: liz at xcalibur dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [2003-01-07 12:55 UTC] liz at xcalibur dot demon dot co dot uk
OK, I had the following code:

<?
$counterfile = '/path/afile;
if (file_exists ($counterfile) == true )
{
        while (( $fp = fopen ($counterfile,"r+")) == false)
        { usleep(5);}
               while (!flock($fp,2))
        { usleep(5); }
        $data = fread($fp,filesize($counterfile));
        $content=explode(" ",$data);
        $content[1]=$content[1]+1;
        if (rewind($fp)!=0)
        {
                $data=implode(" ",$content);
                fwrite($fp,$data,strlen($data));
        }
        flock($fp,3);
        fclose($fp);
}
//header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
//header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                                                      // always modified
//header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
//header ("Pragma: no-cache");                          // HTTP/1.0
header('Content-disposition: filename=setup.exe');
header('Content-type: application/octetstream');
header('Content-length: '.filesize('/path/setup.exe'));
readfile('/path/setup.exe');
?>

It worked before I upgraded to 4.3, so last version was 4.2 I used.

Now, its not doing the headers, its just showing the results of the readfile.. (so my users reported major whine when they went to download my app as I stupidly didnt check that one link)

v4.2 was compiled with 
Running PHP 4.2.2
Zend Engine v1.2.0, Copyright (c) 1998-2002 Zend Technologies

[PHP Modules]
xml
standard
sockets
session
posix
pcre
mysql
imap
ftp
dbase
ctype

v4.3 with

[PHP Modules]
Zend Optimizer
ctype
dbase
ftp
imap
mysql
overload
pcre
posix
session
sockets
standard
tokenizer
xml

[Zend Modules]
Zend Optimizer


(Optimizer irrelevant the 4.2 works with or without optimizer, 4.3 produces the same)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-07 13:19 UTC] liz at xcalibur dot demon dot co dot uk
Oh - I meant to say this is using PHP as CGI, and no this wasnt the CLI version this was deffinately the CGI one. I checked, a ton of times.. As I suddenly thought.
 [2003-01-07 13:24 UTC] liz at xcalibur dot demon dot co dot uk
It seems this only occurs if you do -q to OVERRIDE the default headers, eg, print your own rather than say text/html.... it doesnt print any of them.... none at all! Even though you specifically asked for them. In 4.2 you did -q to suppress default headers but could print your own
 [2003-01-07 17:42 UTC] edink@php.net
php -q will stop output of all headers, not just default ones. So if header() works when -q is not specified, this is not a bug.
 [2003-01-08 05:18 UTC] liz at xcalibur dot demon dot co dot uk
It is a bug if it was the recommended way of overwriting headers and you changed it and failed to tell anyone, so resulting in lots of things stopping to work.

Either its a bug in your documentaiton or you changed a feature.
 [2003-01-08 05:19 UTC] liz at xcalibur dot demon dot co dot uk
Its not 'bogus'
 [2003-01-08 06:12 UTC] edink@php.net
The -q switch has always disabled all header output, not only default headers. Just tested with 4.0.6 and 4.1.2. If you have found a piece of documentation that states otherwise please reopen as documentation problem.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 08:01:32 2025 UTC