php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #6128 header() does not flush properly
Submitted: 2000-08-12 06:24 UTC Modified: 2000-08-17 04:58 UTC
From: garths at cs dot sfu dot ca Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.1pl2 OS: FreeBSD
Private report: No CVE-ID: None
 [2000-08-12 06:24 UTC] garths at cs dot sfu dot ca
Calling header("location: *") should immediately send 
the header to the client (Or if not, flush() or something 
similar should force this. Documentation unclear). This 
does not happen. In the following case, the header only 
gets sent once script execution is finished.

header("Location: http://www.blah.com");
flush();

In this case, however, the header gets sent 
immediately.

header("Location: http://www.blah.com");
ECHO " ";
flush();

This surely can't be the expected behaviour, since there 
shouldn't be any body in a redirect header response, 
and there must be a way to send a header immediately 
(I believe it worked in some previous versions).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-15 11:51 UTC] hholzgra@php.net
headers are collected until the first real (body) output
occurs and then they are sent all at once 

flush() does only work on body output, not headers

as php doesn't know anythnig about HTTP header values
it does not know that there will be no following
output after a "Location:" header

i'll change this one to "feature request" as:

"flush() should process all outstanding headers as if
 real output had occured even if there hasn't been no
 output yet"

although i'm not really sure this is the right thing to do
 [2000-08-17 04:58 UTC] stas@php.net
header() should not immediately send headers, since more headers can follow. All headers are sent in one set when the output of teh script starts.

And this is wrong that redirect can't have a body. It can - and, in fact, even should - for clients that cannot understand redirect code and/or Location: header.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 27 14:01:33 2024 UTC