#23902 [Asn]: header("HTTP/1.0 401 Authorization Required"); failed
| From: | edink@php.net | Date: | Tue, 03 Jun 2003 08:11:19 +0000 |
| Subject: | #23902 [Asn]: header("HTTP/1.0 401 Authorization Required"); failed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-41002@lists.php.net to get a copy of this message | ||
ID: 23902
Updated by: edink@php.net
Reported By: noxter at web dot de
Status: Assigned
Bug Type: CGI related
Operating System: Windows 2000
PHP Version: 4.3.2
Assigned To: edink
New Comment:
cgi.rfc2616_headers directive was added in response to bug #19207.
Later changes to SAPI.c made it malfunction.
Previous Comments:
------------------------------------------------------------------------
[2003-06-03 01:56:09] shane@php.net
Since my testing appears to show that rfc2616_headers *DOES NOT* work
with IIS/5.0, I'm reasigning this to the author of that code. However,
the patch below 'fixes' the (null) problem, and properly allows full
status lines to be used with the authenticate header. This bug is
related to bug 19207.
With rfc2616_headers=1 on IIS/5.0, the following occurs (IIS/5.0 likes
rfc2616_headers=0, oposite of comments in php.ini):
C:\usr\src\php43>wget -S http://localhost/auth.php43d
--23:54:42-- http://localhost/auth.php43d
=> `auth.php43d.4'
Resolving localhost... done.
Connecting to localhost[127.0.0.1]:80... connected.
HTTP request sent, awaiting response...
1 HTTP/1.1 200 OK
2 Server: Microsoft-IIS/5.0
3 Date: Tue, 03 Jun 2003 06:54:42 GMT
4 HTTP/1.0 401 Authorization Required
5 Content-type: text/html
6 X-Powered-By: PHP/4.3.3-dev
7 WWW-Authenticate: Basic realm="example"
[ <=> ] 4 3.91K/s
Index: main/SAPI.c
===================================================================
RCS file: /repository/php4/main/SAPI.c,v
retrieving revision 1.155.2.9
diff -u -d -u -r1.155.2.9 SAPI.c
--- main/SAPI.c 11 Feb 2003 23:30:13 -0000 1.155.2.9
+++ main/SAPI.c 3 Jun 2003 06:48:47 -0000
@@ -456,6 +456,12 @@
static void sapi_update_response_code(int ncode TSRMLS_DC)
{
+ /* if the status code did not change, we do not want
+ to change the status line, and no need to change the code */
+ if (SG(sapi_headers).http_response_code == ncode) {
+ return;
+ }
+
if (SG(sapi_headers).http_status_line) {
efree(SG(sapi_headers).http_status_line);
SG(sapi_headers).http_status_line = NULL;
Index: sapi/cgi/cgi_main.c
===================================================================
RCS file: /repository/php4/sapi/cgi/cgi_main.c,v
retrieving revision 1.190.2.37
diff -u -d -u -r1.190.2.37 cgi_main.c
--- sapi/cgi/cgi_main.c 31 May 2003 17:02:01 -0000 1.190.2.37
+++ sapi/cgi/cgi_main.c 3 Jun 2003 06:48:47 -0000
@@ -303,7 +303,7 @@
if (SG(sapi_headers).http_response_code != 200) {
int len;
- if (rfc2616_headers) {
+ if (rfc2616_headers && SG(sapi_headers).http_status_line) {
len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH,
"%s\r\n", SG(sapi_headers).http_status_line);
------------------------------------------------------------------------
[2003-06-02 14:12:40] shane@php.net
Yeah, I started on a fix for it yesterday and will look at it again
tonight. Not sure who wrote the header stuff, but not checking for
NULL is the problem here.
------------------------------------------------------------------------
[2003-06-02 12:42:46] 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 11:43:14] noxter at web dot de
No difference. HTTP/1.0 or 1.1, the result is alike.
------------------------------------------------------------------------
[2003-06-01 21:01:55] sniper@php.net
What if you sent it as HTTP/1.1:
header("HTTP/1.1 401 Authorization Required");
Does it make any difference?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/23902
--
Edit this bug report at http://bugs.php.net/?id=23902&edit=1