Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33448 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64085 invoked by uid 1010); 27 Nov 2007 04:51:52 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 64070 invoked from network); 27 Nov 2007 04:51:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Nov 2007 04:51:51 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Received: from [204.11.219.139] ([204.11.219.139:54114] helo=mail.lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/40-47481-662AB474 for ; Mon, 26 Nov 2007 23:51:51 -0500 Received: from trainburn-lm-corp-yahoo-com.local (eth3421.qld.adsl.internode.on.net [59.167.216.96]) (authenticated bits=0) by mail.lerdorf.com (8.14.2/8.14.2/Debian-1) with ESMTP id lAR4ovq3017667 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 26 Nov 2007 20:51:09 -0800 Message-ID: <474BA22F.2020608@lerdorf.com> Date: Tue, 27 Nov 2007 14:50:55 +1000 User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: enugroho@spikesource.com CC: PHP Developers Mailing List References: <1196124442.21880.15.camel@ganges.spikesource.com> In-Reply-To: <1196124442.21880.15.camel@ganges.spikesource.com> X-Enigmail-Version: 0.95.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.91.2/4928/Mon Nov 26 10:10:39 2007 on colo.lerdorf.com X-Virus-Status: Clean Subject: Re: [PHP-DEV] Reliable header sending mechanism in php 6 From: rasmus@lerdorf.com (Rasmus Lerdorf) Ezra Nugroho wrote: > Can I ask for the following support, at least to begin conversation > about it if it hasn't been done before. > > Currently, the header() function still carries the following warning in > its online documentation: > > "Remember that header() must be called before any actual output is sent, > either by normal HTML tags, blank lines in a file, or from PHP. It is a > very common error to read code with include(), or require(), functions, > or another file access function, and have spaces or empty lines that are > output before header() is called. The same problem exists when using a > single PHP/HTML file." > > This is quite annoying since this makes header() or setcookie() calls to > be unreliable. > > I am aware that it can be done more reliably by turning the output > buffering on. This is less of an issue if you are writing your own > webapp. However, this is much more difficult if a person writes a > library for other people's consumptions. The library cannot enforce > output buffering in the webapp. > > Can we please give it a thought in PHP 6? Maybe by turning output > buffering on by default, or even by enforcing output buffering. > > In Java, you can get the request object, and the response object of a > web request. I find this very useful and reliable. > > Any thoughts or comments about this? There is nothing unreliable about is as far as I am concerned. You have full control over output buffering from your script. Forcing people to buffer output by default will mean higher memory usage and higher latency for existing scripts with no gain given their code is working today. -Rasmus