How to send custom status codes using Kohana 3?
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
.
精彩评论