header("HTTP/1.0 401 Authorization Required"); failed
| Bug #23902 | header("HTTP/1.0 401 Authorization Required"); failed | ||||
|---|---|---|---|---|---|
| Submitted: | 2003-05-30 12:16 UTC | Modified: | 2003-06-03 05:15 UTC | ||
| From: | noxter at web dot de | Assigned: | edink (profile) | ||
| Status: | Closed | Package: | CGI/CLI related | ||
| PHP Version: | 4.3.2 | OS: | Windows 2000 | ||
| Private report: | No | CVE-ID: | None | ||
[2003-05-30 12:16 UTC] noxter at web dot de
The follow example failed by php as common gateway interface application. This problem is common and not specified of a server. Testing with apache, iis, devwex ... . The option cgi.rfc2616_headers = 1 is setting in the php.ini.
<?
header("HTTP/1.0 401 Authorization Required");
header("WWW-Authenticate: Basic realm=\"example\"");
?>
the response of Server :
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Fri, 30 May 2003 17:04:01 GMT
(null)
Content-type: text/html
X-Powered-By: PHP/4.3.2
WWW-Authenticate: Basic realm="example"
the respone of CGI:
(null)
Content-type: text/html
X-Powered-By: PHP/4.3.2
WWW-Authenticate: Basic realm="example"
...
the respone correct is:
HTTP/1.0 401 Authorization Required
Content-type: text/html
X-Powered-By: PHP/4.3.2
WWW-Authenticate: Basic realm="example"
...
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-06-01 21:01 UTC] sniper@php.net
What if you sent it as HTTP/1.1: header("HTTP/1.1 401 Authorization Required"); Does it make any difference?[2003-06-02 11:43 UTC] noxter at web dot de
[2003-06-02 12:42 UTC] sniper@php.net
This works: <?php header("WWW-Authenticate: Basic realm=\"example\""); header("HTTP/1.0 401 Authorization Required"); ?> For Shane: Seems that when line sapi/cgi/cgi_main.c:307 is reached, the SG(sapi_headers).http_status_line is reset to NULL in line main/SAPI.c:591 (matters only when cgi.rfc2616_headers = 1). Not sure if this is bug in SAPI.c (or not even a bug) but CGI SAPI should handle this a bit better, at least by not setting that "(null)\r\n" header line.[2003-06-02 14:12 UTC] shane@php.net
[2003-06-03 01:56 UTC] shane@php.net
[2003-06-03 03:11 UTC] edink@php.net
[2003-06-03 05:15 UTC] edink@php.net
[2003-06-04 18:17 UTC] ptchristendom at yahoo dot com
On windows 2003, PHP 4.3.2, any location header at all causes this. You can also verify it from the command line: script.php contains this line only: <? header('Location: http://localhost.com/page.html'); ?> Output: d:\php-4.3.2\php script.php (null) Content-type: text/html; charset=iso-8859-1 X-Powered-By: PHP/4.3.2 Location: http://localhost.com/page.html Setting cgi.rfc2616_headers = 0 is a workaround for this, at least until the bug is fixed.[2003-06-05 04:05 UTC] jan at kneschke dot de
[2010-04-20 08:49 UTC] dim_logaras at windowslive dot com
[2010-04-20 08:55 UTC] taverna_ambelos at windowslive dot com
[2010-08-27 22:48 UTC] mmoohh00 at yahoo dot com
[2010-09-15 01:32 UTC] enzinho_vrb at hotmail dot com