Skip to content

Commit

Permalink
Merge pull request #6 from oat-sa/feature/TAO-6182_add_missing-http-m…
Browse files Browse the repository at this point in the history
…ethods

add missing HTTP verbs
  • Loading branch information
Jérôme Bogaerts authored May 17, 2018
2 parents 1749f2f + 8a8d588 commit f92f71c
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions core/Request.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
* Request class
* TODO Request class documentation.
*
* @author J�r�me Bogaerts <[email protected]> <[email protected]>
* @author Jérôme Bogaerts <[email protected]> <[email protected]>
*/
class Request
{
const HTTP_GET = 'GET';
const HTTP_POST = 'POST';
const HTTP_PUT ='PUT';
const HTTP_DELETE = 'DELETE';
const HTTP_HEAD = 'HEAD';

const HTTP_GET = 'GET';
const HTTP_POST = 'POST';
const HTTP_PUT = 'PUT';
const HTTP_DELETE = 'DELETE';
const HTTP_HEAD = 'HEAD';
const HTTP_OPTIONS = 'OPTIONS';
const HTTP_PATCH = 'PATCH';

protected $parameters = array();
protected $rawParameters = array();
protected $method;
Expand Down Expand Up @@ -158,8 +160,18 @@ public function isDelete()
public function isHead()
{
return $this->getMethod() == self::HTTP_HEAD;
}

public function isOptions()
{
return $this->getMethod() == self::HTTP_OPTIONS;
}

public function isPatch()
{
return $this->getMethod() == self::HTTP_PATCH;
}

public function getUserAgent()
{
return $_SERVER['USER_AGENT'];
Expand Down Expand Up @@ -223,7 +235,6 @@ public function accept($mime){
private function defineMethod()
{
$methodAsString = $_SERVER['REQUEST_METHOD'];

switch ($methodAsString)
{
case 'GET':
Expand All @@ -245,8 +256,13 @@ private function defineMethod()
case 'HEAD':
$method = self::HTTP_HEAD;
break;
case 'OPTIONS':
$method = self::HTTP_OPTIONS;
break;
case 'PATCH':
$method = self::HTTP_PATCH;
break;
}

return $method;
}

Expand Down

0 comments on commit f92f71c

Please sign in to comment.