开发者

How to send custom status codes using Kohana 3?

开发者 https://www.devze.com 2023-03-26 16:28 出处:网络
I am trying to return custom status codes using Kohana 3.1开发者_如何学C, like so : $this->response->status(420);

I am trying to return custom status codes using Kohana 3.1开发者_如何学C, like so :

$this->response->status(420);

Kohana says so :

"Kohana_Response::status unknown status value : 418"

How do I force Kohana to send such a status code?

FYI, the server I am using is Nginx, and I have to catch this status code there in Nginx.


If you check the source code to the Response::status() method you will that Kohana has a whitelist of valid response codes.

Either override the Response class (using kohana's transparent extension) and add your new status to the $messages array.

Or, since it is a public property add the entry to Response::$messages in bootstrap.php.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号