Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29122 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95043 invoked by uid 1010); 1 May 2007 09:41:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 95028 invoked from network); 1 May 2007 09:41:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 May 2007 09:41:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=thetaphi@php.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=thetaphi@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 80.190.230.99 cause and error) X-PHP-List-Original-Sender: thetaphi@php.net X-Host-Fingerprint: 80.190.230.99 www.troja.net Linux 2.5 (sometimes 2.4) (4) Received: from [80.190.230.99] ([80.190.230.99:36396] helo=mail.troja.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/E4-40722-A4B07364 for ; Tue, 01 May 2007 05:41:31 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.troja.net (Postfix) with ESMTP id 1646A2973A; Tue, 1 May 2007 11:41:48 +0200 (CEST) Received: from mail.troja.net ([127.0.0.1]) by localhost (cyca.troja.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26011-05; Tue, 1 May 2007 11:41:44 +0200 (CEST) Received: from VEGA (port-83-236-62-78.dynamic.qsc.de [83.236.62.78]) (using SSLv3 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.troja.net (Postfix) with ESMTP id 911DF29723; Tue, 1 May 2007 11:41:44 +0200 (CEST) To: "'Christian Schneider'" , References: Date: Tue, 1 May 2007 11:41:25 +0200 Message-ID: <000c01c78bd4$e3534000$0201a8c0@VEGA> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 In-Reply-To: Thread-Index: AceLRbgJYI+aLnmsRQOOEyX+aww22gAjUdUg X-Virus-Scanned: amavisd-new at troja.net Subject: RE: [PHP-DEV] Setting HTTP results code vs. HTTP type From: thetaphi@php.net ("Uwe Schindler") > - Update the PHP header() documentation to mention this. I was also > thinking that supporting/documenting header(null, true, 404); or the > like would be nice for people who only want to set the return code and > leave the HTTP type unchanged. I think this would bet he best approach, to give the PHP a users a _consistent_ way (consistent through all SAPIs) to set the http response code without changing protocols. Your problem only occurs with apache, as apache gives PHP the possibility to change the HTTP protocol version. Other SAPIs, like my NSAPI one, cannot do this because the protocol is the servers task and modules are not allowed to change it in a wrong way. The problem with setting the response code is: * Some PHP scripts use header('Status: 301') to set response code. Problem here: This only works with CGI and Apache. The problem here is in PHP SAPI code: PHP only checks for ('HTTP/...') header strings and extracts status code and protocol version from it. The string 'HTTP/..' is never send to the SAPI. In case of 'Status: ', SAPI sends the header as a _normal_ HTTP header to the webserver -> Apache maps this, CGI also because specs want this. * Some scripts use header('HTTP/1.0 301 Moved Permanently'). Problem here: You must supply a HTTP version (this seems to be a problem in Apache), and you must supply the textual representation (but most/all? SAPIs ignore the textual representation). So header('HTTP/1.0 301 X') would be OK. What we need is: 1) a consistent parsing of header() inputs before sending to the underlying SAPI. This means also parsing for 'Status: XXX' and setting the status code. The later SAPI then will generate the correct parameters to be sent to the server (in case of CGI it will "regenerate" a Status:-header). 2) a function to simply set the status code without changing anything other. 1. supplies such a method with 'Status: 301' if it is correctly implemented. If nobody is against it I would try to implement a consistent header parsing for SAPI...