Skip to content

Commit

Permalink
add missing PATCH method
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Dec 28, 2015
1 parent 363d799 commit a2637af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions library/PSX/Dispatch/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public function createRequest()
// create body
$requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null;

if (in_array($requestMethod, array('POST', 'PUT', 'DELETE'))) {
// as long as we support PHP < 5.6 we must use an BufferedStream
if (in_array($requestMethod, array('POST', 'PUT', 'DELETE', 'PATCH'))) {
// as long as we support PHP < 5.6 we must use a BufferedStream
// since the php://input stream can only be read once
$body = new BufferedStream(new TempStream(fopen('php://input', 'r')));
}
Expand All @@ -97,7 +97,7 @@ public function createRequest()
$actionUri = trim(strstr($headers['SOAPACTION'] . ';', ';', true), '" ');
$soapMethod = parse_url($actionUri, PHP_URL_FRAGMENT);

if (in_array($soapMethod, array('GET', 'POST', 'PUT', 'DELETE'))) {
if (in_array($soapMethod, array('GET', 'POST', 'PUT', 'DELETE', 'PATCH'))) {
$method = $soapMethod;
}
}
Expand All @@ -119,7 +119,7 @@ protected function getRequestMethod()
if (isset($_SERVER['REQUEST_METHOD'])) {
// check for X-HTTP-Method-Override
if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']) &&
in_array($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'], array('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT'))) {
in_array($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'], array('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'))) {
return $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
} else {
return $_SERVER['REQUEST_METHOD'];
Expand Down
2 changes: 1 addition & 1 deletion library/PSX/Http/Handler/Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getResources()

public function add($method, $url, Closure $handler)
{
if (!in_array($method, array('GET', 'POST', 'PUT', 'DELETE'))) {
if (!in_array($method, array('GET', 'POST', 'PUT', 'DELETE', 'PATCH'))) {
throw new Exception('Invalid http request method');
}

Expand Down

0 comments on commit a2637af

Please sign in to comment.