diff --git a/src/Client.php b/src/Client.php index 05777f1356..07f39fb4e1 100755 --- a/src/Client.php +++ b/src/Client.php @@ -355,7 +355,7 @@ public function getUri() */ public function setMethod($method) { - $this->getRequest()->setMethod($method); + $method = $this->getRequest()->setMethod($method)->getMethod(); if (($method == Request::METHOD_POST || $method == Request::METHOD_PUT || $method == Request::METHOD_DELETE) && empty($this->encType)) { diff --git a/src/Request.php b/src/Request.php index adabc46a9c..cadc58a831 100644 --- a/src/Request.php +++ b/src/Request.php @@ -145,7 +145,8 @@ public static function fromString($string) */ public function setMethod($method) { - if (!defined('static::METHOD_'.strtoupper($method))) { + $method = strtoupper($method); + if (!defined('static::METHOD_'.$method)) { throw new Exception\InvalidArgumentException('Invalid HTTP method passed'); } $this->method = $method; diff --git a/src/Response.php b/src/Response.php index 5d28aee043..9c50c88fa7 100644 --- a/src/Response.php +++ b/src/Response.php @@ -14,6 +14,7 @@ class Response extends Message implements ResponseDescription const STATUS_CODE_CUSTOM = 0; const STATUS_CODE_100 = 100; const STATUS_CODE_101 = 101; + const STATUS_CODE_102 = 102; const STATUS_CODE_200 = 200; const STATUS_CODE_201 = 201; const STATUS_CODE_202 = 202; @@ -21,6 +22,8 @@ class Response extends Message implements ResponseDescription const STATUS_CODE_204 = 204; const STATUS_CODE_205 = 205; const STATUS_CODE_206 = 206; + const STATUS_CODE_207 = 207; + const STATUS_CODE_208 = 208; const STATUS_CODE_300 = 300; const STATUS_CODE_301 = 301; const STATUS_CODE_302 = 302; @@ -48,6 +51,11 @@ class Response extends Message implements ResponseDescription const STATUS_CODE_416 = 416; const STATUS_CODE_417 = 417; const STATUS_CODE_418 = 418; + const STATUS_CODE_422 = 422; + const STATUS_CODE_423 = 423; + const STATUS_CODE_424 = 424; + const STATUS_CODE_425 = 425; + const STATUS_CODE_426 = 426; const STATUS_CODE_428 = 428; const STATUS_CODE_429 = 429; const STATUS_CODE_431 = 431; @@ -57,6 +65,9 @@ class Response extends Message implements ResponseDescription const STATUS_CODE_503 = 503; const STATUS_CODE_504 = 504; const STATUS_CODE_505 = 505; + const STATUS_CODE_506 = 506; + const STATUS_CODE_507 = 507; + const STATUS_CODE_508 = 508; const STATUS_CODE_511 = 511; /**#@-*/ @@ -80,6 +91,7 @@ class Response extends Message implements ResponseDescription // INFORMATIONAL CODES 100 => 'Continue', 101 => 'Switching Protocols', + 102 => 'Processing', // SUCCESS CODES 200 => 'OK', 201 => 'Created', @@ -88,6 +100,8 @@ class Response extends Message implements ResponseDescription 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', + 207 => 'Multi-status', + 208 => 'Already Reported', // REDIRECTION CODES 300 => 'Multiple Choices', 301 => 'Moved Permanently', @@ -117,6 +131,11 @@ class Response extends Message implements ResponseDescription 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 425 => 'Unordered Collection', + 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', @@ -127,6 +146,9 @@ class Response extends Message implements ResponseDescription 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', + 506 => 'Variant Also Negotiates', + 507 => 'Insufficient Storage', + 508 => 'Loop Detected', 511 => 'Network Authentication Required', ); diff --git a/test/ClientTest.php b/test/ClientTest.php new file mode 100644 index 0000000000..d542ef9f03 --- /dev/null +++ b/test/ClientTest.php @@ -0,0 +1,18 @@ +setMethod('post'); + $this->assertEquals(Client::ENC_URLENCODED, $client->getEncType()); + } +} diff --git a/test/RequestTest.php b/test/RequestTest.php index db928c1981..9ca9e2ac76 100644 --- a/test/RequestTest.php +++ b/test/RequestTest.php @@ -78,6 +78,13 @@ public function testRequestCanSetAndRetrieveValidMethod() $this->assertEquals('POST', $request->getMethod()); } + public function testRequestCanAlwaysForcesUppecaseMethodName() + { + $request = new Request(); + $request->setMethod('get'); + $this->assertEquals('GET', $request->getMethod()); + } + public function testRequestCanSetAndRetrieveUri() { $request = new Request();