Are these REST HTTP response codes right, and what about the Content-Type?
- by talentedmrjones
I'm writing a controller helper that sets the proper response headers for my REST controller action. It's pasted below and should be simplified enough for those who aren't familiar with Zend Framework to understand what I'm doing.
My question is: Are these codes correct for their respective responses, and in the case of "access denied" do I use a 401 or 403?
Also, in case of responding with an error, I understand I should be placing a message in the response body, but should I set the "Content-Type" to "text/plain"?
<?php
class App_Controller_Helper_RestResponse extends Zend_Controller_Action_Helper_Abstract
{
public function denied()
{
// 403 or 401?
}
public function notFound()
{
// 404
}
public function created()
{
// 201
}
public function deleted()
{
// 204
}
public function redirect()
{
// 301
// new url
}
public function malformed()
{
// 400
}
public function gone()
{
// 410
}
}