diff --git a/lib/Cake/Network/Http/HttpResponse.php b/lib/Cake/Network/Http/HttpResponse.php index 90c622588..6a0d768d6 100644 --- a/lib/Cake/Network/Http/HttpResponse.php +++ b/lib/Cake/Network/Http/HttpResponse.php @@ -116,12 +116,12 @@ class HttpResponse implements ArrayAccess { } /** - * If return is 200 (OK) + * If return is a valid 2xx (OK or Successful) * * @return boolean */ public function isOk() { - return $this->code == 200; + return in_array($this->code, array(200, 201, 202, 203, 204, 205, 206)); } /** diff --git a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php index 2f9809821..495a70a8b 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php @@ -157,12 +157,36 @@ class HttpResponseTest extends CakeTestCase { $this->assertFalse($this->HttpResponse->isOk()); $this->HttpResponse->code = -1; $this->assertFalse($this->HttpResponse->isOk()); - $this->HttpResponse->code = 201; - $this->assertFalse($this->HttpResponse->isOk()); $this->HttpResponse->code = 'what?'; $this->assertFalse($this->HttpResponse->isOk()); $this->HttpResponse->code = 200; $this->assertTrue($this->HttpResponse->isOk()); + $this->HttpResponse->code = 201; + $this->assertTrue($this->HttpResponse->isOk()); + $this->HttpResponse->code = 202; + $this->assertTrue($this->HttpResponse->isOk()); + $this->HttpResponse->code = 203; + $this->assertTrue($this->HttpResponse->isOk()); + $this->HttpResponse->code = 204; + $this->assertTrue($this->HttpResponse->isOk()); + $this->HttpResponse->code = 205; + $this->assertTrue($this->HttpResponse->isOk()); + $this->HttpResponse->code = 206; + $this->assertTrue($this->HttpResponse->isOk()); + $this->HttpResponse->code = 207; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 208; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 209; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 210; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 226; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 288; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 301; + $this->assertFalse($this->HttpResponse->isOk()); } /**