Hi,<br><br>I want to use basic authentication (<a href="http://en.wikipedia.org/wiki/Basic_access_authentication">http://en.wikipedia.org/wiki/Basic_access_authentication</a>).<br><br>But "set field" in response is not compatible with the "response_set_status" :<br>
<br><b>1) test.kl1</b><br>===========================================================<br><%<br>int a,b,c,d,e;<br>a=response_set_status(response, 401);<br>// result would be => HTTP/1.0 401 Authorization Required<br>
<br>b=response_set_field(response,"WWW-Authenticate", "Basic realm=\"Identification\"");<br>// result would be => WWW-Authenticate: Basic realm="Identification"<br><br>c=response_set_field(response,"Cache-Control","no-cache");<br>
// result would be => Cache-Control: no-cache<br><br>d=response_set_field(response,"Connection","close");<br>// result would be => Connection: close<br><br>e=response_enable_caching(response);<br>
<br>// io_printf(out,"Authorization :'%s'\n",request_get_field(request,"Authorization"));<br>%><br>===========================================================<br>The result value of a,b,c,d,e are OK (zero).<br>
<br><br><b>2) The web-browser request</b> (tests also with telnet)<br>======================<br>GET /test.kl1 HTTP/1.0<br>======================<br><br><b><br>3) Receive response</b><br>======================<br>HTTP/1.0 401 Unauthorized<br>
Server: klone/2.1.0<br>Date: Tue, 29 Apr 2008 13:46:02 GMT<br>Cache-Control: no-cache, must-revalidate<br>Expires: Mon, 1 Jan 1990 05:00:00 GMT<br>Pragma: no-cache<br><br><br>HTTP/1.0 401 Unauthorized<br>Server: klone/2.1.0<br>
Date: Tue, 29 Apr 2008 13:46:02 GMT<br>Cache-Control: no-cache, must-revalidate<br>Expires: Mon, 1 Jan 1990 05:00:00 GMT<br>Pragma: no-cache<br><br><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>401 Unauthorized</title></head><br>
<body><h1>Unauthorized</h1><p>URL: /test.kl1</p><hr><address>KLone/2.1.0 web server - <a href="http://www.koanlogic.com">www.koanlogic.com</a><br></address></body></html><br>
======================<br><br><b>4) Attended response</b><br>======================<br>HTTP/1.0 401 Unauthorized<br>Date: Tue, 29 Apr 2008 13:45:29 GMT<br>WWW-Authenticate: Basic realm="Identification"<br>Cache-Control: no-cache<br>
Connection: close<br>======================<br><br>There are two problems:<br>- the 'set_field' are not applied<br>- the default error page overload the 'set_status' function (while a 200 response of status do not disturb the use of 'set_field')<br>
<br>The 401 response of status is "necessary" for the 'WWW-Authenticate' header field.<br><br><br>Thank you.<br clear="all"><br>-- <br>Mickaël AUGER<br><a href="mailto:mickael.auger@gmail.com">mickael.auger@gmail.com</a>