Browse Source

Client isOk() judged between 200 and 204.

Kazuki_Kamizuru 8 years ago
parent
commit
9dbdfd5cdb

+ 14 - 0
src/Http/Client/Message.php

@@ -46,6 +46,20 @@ class Message
     const STATUS_ACCEPTED = 202;
 
     /**
+     * HTTP 203 code
+     *
+     * @var int
+     */
+    const STATUS_NON_AUTHORITATIVE_INFORMATION = 203;
+
+    /**
+     * HTTP 204 code
+     *
+     * @var int
+     */
+    const STATUS_NO_CONTENT = 204;
+
+    /**
      * HTTP 301 code
      *
      * @var int

+ 3 - 1
src/Http/Client/Response.php

@@ -236,7 +236,9 @@ class Response extends Message implements ResponseInterface
         $codes = [
             static::STATUS_OK,
             static::STATUS_CREATED,
-            static::STATUS_ACCEPTED
+            static::STATUS_ACCEPTED,
+            static::STATUS_NON_AUTHORITATIVE_INFORMATION,
+            static::STATUS_NO_CONTENT
         ];
 
         return in_array($this->code, $codes);

+ 14 - 0
tests/TestCase/Http/Client/ResponseTest.php

@@ -216,6 +216,20 @@ XML;
         $this->assertTrue($response->isOk());
 
         $headers = [
+            'HTTP/1.1 203 Non-Authoritative Information',
+            'Content-Type: text/html'
+        ];
+        $response = new Response($headers, 'ok');
+        $this->assertTrue($response->isOk());
+
+        $headers = [
+            'HTTP/1.1 204 No Content',
+            'Content-Type: text/html'
+        ];
+        $response = new Response($headers, 'ok');
+        $this->assertTrue($response->isOk());
+
+        $headers = [
             'HTTP/1.1 301 Moved Permanently',
             'Content-Type: text/html'
         ];