【发布时间】:2013-04-19 09:24:53
【问题描述】:
当我在Kohana 3.3 中抛出HTTP_Exception_401 时,我收到以下错误:
Kohana_Exception [ 0 ]: A 'www-authenticate' header must be specified for a HTTP 401 Unauthorized
现在明显的问题是 www-authenticate 标头尚未设置。
我正在努力弄清楚如何以及在何处设置它。
我尝试了以下方法,但抛出了同样的错误:
使用原生 PHP header():
header('WWW-Authenticate: realm="My Website"');
throw new HTTP_Exception_401('Authorisation Required');
向请求对象添加标头:
$this->request->header('WWW-Authenticate', 'realm="My Website"');
throw new HTTP_Exception_401('Authorisation Required');
我正在尝试从控制器抛出异常。
任何帮助将不胜感激。
【问题讨论】:
标签: php kohana http-status-code-401 kohana-3.3 www-authenticate