-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from oat-sa/feature/TAO-6182_add_missing-http-m…
…ethods add missing HTTP verbs
- Loading branch information
Showing
1 changed file
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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']; | ||
|
@@ -223,7 +235,6 @@ public function accept($mime){ | |
private function defineMethod() | ||
{ | ||
$methodAsString = $_SERVER['REQUEST_METHOD']; | ||
|
||
switch ($methodAsString) | ||
{ | ||
case 'GET': | ||
|
@@ -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; | ||
} | ||
|
||
|