Bug #15409 Updated: Printing header works only if followed by a print statement
| From: | priebe at mi-corporation dot com | Date: | Wed, 06 Feb 2002 21:17:21 +0000 |
| Subject: | Bug #15409 Updated: Printing header works only if followed by a print statement | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-79410@lists.php.net to get a copy of this message | ||
ID: 15409
Updated by: priebe@mi-corporation.com
Reported By: priebe@mi-corporation.com
Status: Feedback
Bug Type: Apache related
Operating System: RH Linux 7.2 (kernel2.4.9-13smp)
PHP Version: 4.1.1
New Comment:
OK -- if you can't reproduce it, it's likely the result of the patch I
applied to our copy. My apologies for entering this bug report before
testing against a standard 4.1.1 install.
But if you happen to know how to attack 15209... :-P
Previous Comments:
------------------------------------------------------------------------
[2002-02-06 16:14:18] derick@php.net
But I was unable to reproduce it here on RH 7.2/4.1.1
Derick
------------------------------------------------------------------------
[2002-02-06 16:13:31] priebe@mi-corporation.com
Of course the headers are only sent when output is done. I understand
that. But the problem is that if there is no output other than the
header, the header is not displayed at all!
I just realized that a patch I quickly threw together for bug 15209 may
be to blame. I'm quite confident that 15209 is a legitimate bug that
needs attention (although nobody seems to have done anything with it).
Before anybody wastes time on this bug, 15209 should take priority.
------------------------------------------------------------------------
[2002-02-06 16:10:33] derick@php.net
Who told you you can print a header like that?
Anyway... the headers are indeed only send when some output is done.
------------------------------------------------------------------------
[2002-02-06 16:05:15] priebe@mi-corporation.com
The following script works when php is called from the command line:
<?php
print header("Location: http://www.yahoo.com/");
exit;
?>
[myhost] php test.php
Location: http://www.yahoo.com/
Content-type: text/html
But when called via the Apache server (1.3.20), I get nothing (and
nothing in the error logs, so I don't think PHP is crashing):
[myhost] telnet localhost 80
Trying localhost...
Connected to localhost.
Escape character is '^]'.
GET /test.php HTTP/1.0
Connection closed by foreign host.
But if I print some non-empty string after I print the header, it
works:
<?php
print header("Location: http://www.yahoo.com/");
print "\n";
exit;
?>
[myhost] telnet localhost 80
Trying localhost...
Connected to localhost.
Escape character is '^]'.
GET /test.php HTTP/1.0
HTTP/1.1 302 Found
Date: Wed, 06 Feb 2002 21:01:52 GMT
Server: Apache/1.3.20 (Unix) (Red-Hat/Linux) mod_ssl/2.8.4
OpenSSL/0.9.6b DAV/1.0.2
Location: http://www.yahoo.com/
Connection: close
Content-Type: text/html
This is not restricted to the Location header; other headers do not
display either, unless followed by some non-null print statement.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15409&edit=1