Skip to content
Permalink
Browse files

Make other common 20x response count as ok.

  • Loading branch information...
markstory committed Dec 26, 2012
1 parent d70934d commit 873d0e4806462e9d3d62fafe4edab8a999d49edf
Showing with 20 additions and 1 deletion.
  1. +6 −1 lib/Cake/Network/Http/Response.php
  2. +14 −0 lib/Cake/Test/TestCase/Network/Http/ResponseTest.php
@@ -26,6 +26,8 @@
class Response {
const STATUS_OK = 200;
const STATUS_CREATED = 201;
const STATUS_ACCEPTED = 202;
/**
* The status code of the response.
@@ -102,7 +104,10 @@ protected function _normalizeHeader($name) {
* @return boolean
*/
public function isOk() {
return $this->_code == static::STATUS_OK;
return in_array(
$this->_code,
[static::STATUS_OK, static::STATUS_CREATED, static::STATUS_ACCEPTED]
);
}
/**
@@ -57,6 +57,20 @@ public function testIsOk() {
$response = new Response($headers, 'ok');
$this->assertTrue($response->isOk());
$headers = [
'HTTP/1.1 201 Created',
'Content-Type: text/html'
];
$response = new Response($headers, 'ok');
$this->assertTrue($response->isOk());
$headers = [
'HTTP/1.1 202 Accepted',
'Content-Type: text/html'
];
$response = new Response($headers, 'ok');
$this->assertTrue($response->isOk());
$headers = [
'HTTP/1.1 301 Moved Permanently',
'Content-Type: text/html'

0 comments on commit 873d0e4

Please sign in to comment.
You can’t perform that action at this time.