|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-09-04 21:30 UTC] kalowsky@php.net
[2002-09-05 11:22 UTC] Wendell at thePinegars dot com
[2002-09-24 11:48 UTC] jmoore@php.net
[2002-09-24 13:03 UTC] Wendell at thePinegars dot com
[2002-11-15 04:13 UTC] edink@php.net
[2002-11-22 04:17 UTC] edink@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 04:00:01 2025 UTC |
The following code fragment works great with PHP 4.2.2 on IIS: Header("WWW-authenticate: basic realm=Logon"); Header("HTTP/1.1 401 Unauthorized"); echo "<HTML>\n"; echo " <HEAD>\n"; echo " <TITLE>Authorization Required</TITLE>\n"; echo " </HEAD>\n"; echo " <BODY BGCOLOR=#FFFFFF TEXT=#000000>\n"; echo " Invalid username and password with which to access this webpage.<P><br><br>\n"; echo " </BODY>\n"; echo "</HTML>\n"; exit; This code works correctly in 4.2.2. It sets the status of the page to 401 and makes the browser prompt for the password. However using php-cgi.exe in the latest 4.3.0 development builds in IIS the code does not work. The browser receive a "HTTP/1.1 200 OK" instead of "HTTP/1.1 401 Unauthorized". If I simply run the CGI script from the command prompt using php-cgi.exe in 4.3.0 I get the following: Status: 401 Content-type: text/html WWW-authenticate: basic realm=Logon <HTML> <HEAD> <TITLE>Authorization Required</TITLE> </HEAD> <BODY BGCOLOR=#FFFFFF TEXT=#000000> Invalid username and password with which to access this webpage.<P><br><br> </BODY> </HTML> Running php.exe 4.2.2 from the console I get the following: HTTP/1.1 401 Unauthorized Content-type: text/html WWW-authenticate: basic realm=Logon <HTML> <HEAD> <TITLE>Authorization Required</TITLE> </HEAD> <BODY BGCOLOR=#FFFFFF TEXT=#000000> Invalid username and password with which to access this webpage.<P><br><br> </BODY> </HTML> Noticed that php 4.2.2 correctly returns the HTTP page status as "HTTP/1.1 401 Unauthorized" and php 4.3.0 only returns the tag "Status: 401". The new tag "Status: 401" does not work in IIS, it needs to be the full "HTTP/1.1 401 Unauthorized".