Hiawatha version: 9.8
Operating System: Debian
Hi Hugo,
When I access an folder with a .htaccess file, and fail to authenticate, I nicely get a return header with 401
Request Method:GET
Status Code:401 Unauthorized
HTTP/1.1 401 Unauthorized
Date: Fri, 12 Dec 2014 20:11:08 GMT
Server: Hiawatha v9.8
Accept-Ranges: bytes
Connection: keep-alive
WWW-Authenticate: Basic realm="Hallo"
Content-Length: 677
Content-Type: text/html
But when I create a php file with:
<?php
header('WWW-Authenticate: Basic realm="401 Test"');
header('HTTP/1.1 401 Unauthorized');
?>
Then I get the response with 200, but I expected 401:
Request Method:GET
Status Code:200 OK
Request Headersview parsed
GET /401.php HTTP/1.1
Response Headersview source
Connection:keep-alive
Content-Encoding:gzip
Content-type:text/html
Date:Fri, 12 Dec 2014 20:16:48 GMT
Server:Hiawatha v9.8
Transfer-Encoding:chunked
Vary:Accept-Encoding
WWW-Authenticate:Basic realm="401 Test"
I do not have any ErrorHandler specified in my hiawatha.conf.
I want to create RESTFUL api's and catch the return value with (for now) basic authentication. So In javascript I want to catch a 401:
...
if (http_request.readyState === 4 && http_request.status === 401) {
...
Although my 401.php page is found correctly, so 200, I would expect a 401, because my header does mention that.
Thanks,
Ré
PS: I will upgrade to 9.9