Permalink
Browse files

Merge branch 'mathmarques-allow-all-http-valid-methods-3.x' into 3.x

  • Loading branch information...
akrabat committed Apr 17, 2017
2 parents 1365d12 + c491a0c commit 7d62584968691ba2f897e9dafc7f357e80e0c4ca
Showing with 12 additions and 3 deletions.
  1. +2 −1 Slim/Http/Request.php
  2. +10 −2 tests/Http/RequestTest.php
View
@@ -114,6 +114,7 @@ class Request extends Message implements ServerRequestInterface
* Valid request methods
*
* @var string[]
* @deprecated
*/
protected $validMethods = [
'CONNECT' => 1,
@@ -349,7 +350,7 @@ protected function filterMethod($method)
}
$method = strtoupper($method);
if (!isset($this->validMethods[$method])) {
if (preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method) !== 1) {
throw new InvalidMethodException($this, $method);
}
View
@@ -74,12 +74,20 @@ public function testWithMethod()
$this->assertAttributeEquals('PUT', 'originalMethod', $request);
}
public function testWithAllAllowedCharactersMethod()
{
$request = $this->requestFactory()->withMethod("!#$%&'*+.^_`|~09AZ-");
$this->assertAttributeEquals("!#$%&'*+.^_`|~09AZ-", 'method', $request);
$this->assertAttributeEquals("!#$%&'*+.^_`|~09AZ-", 'originalMethod', $request);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testWithMethodInvalid()
{
$this->requestFactory()->withMethod('FOO');
$this->requestFactory()->withMethod('B@R');
}
public function testWithMethodNull()
@@ -208,7 +216,7 @@ public function testCreateRequestWithInvalidMethodString()
$cookies = [];
$serverParams = [];
$body = new RequestBody();
$request = new Request('FOO', $uri, $headers, $cookies, $serverParams, $body);
$request = new Request('B@R', $uri, $headers, $cookies, $serverParams, $body);
}
/**

0 comments on commit 7d62584

Please sign in to comment.