diff --git a/src/Routing/Route/Route.php b/src/Routing/Route/Route.php index 57d7b10a28a..2c02c418905 100644 --- a/src/Routing/Route/Route.php +++ b/src/Routing/Route/Route.php @@ -78,16 +78,6 @@ class Route { */ protected $_name = null; -/** - * HTTP header shortcut map. Used for evaluating header-based route expressions. - * - * @var array - */ - protected $_headerMap = [ - 'type' => 'content_type', - 'server' => 'server_name' - ]; - /** * List of connected extensions for this route. * @@ -283,29 +273,6 @@ public function parse($url) { } } - foreach ($this->defaults as $key => $val) { - $key = (string)$key; - if ($key[0] === '[' && preg_match('/^\[(\w+)\]$/', $key, $header)) { - if (isset($this->_headerMap[$header[1]])) { - $header = $this->_headerMap[$header[1]]; - } else { - $header = 'http_' . $header[1]; - } - $header = strtoupper($header); - - $val = (array)$val; - $h = false; - - foreach ($val as $v) { - if ($request->env($header) === $v) { - $h = true; - } - } - if (!$h) { - return false; - } - } - } array_shift($route); $count = count($this->keys); for ($i = 0; $i <= $count; $i++) { diff --git a/tests/TestCase/Routing/Route/RouteTest.php b/tests/TestCase/Routing/Route/RouteTest.php index 7ee10c20d36..511edc95e6b 100644 --- a/tests/TestCase/Routing/Route/RouteTest.php +++ b/tests/TestCase/Routing/Route/RouteTest.php @@ -719,38 +719,6 @@ public function testMatchWithMultipleHttpMethodConditions() { $this->assertEquals('/sample', $route->match($url)); } -/** - * Test that the [type] condition works. - * - * @return void - */ - public function testParseWithContentTypeCondition() { - $_SERVER['REQUEST_METHOD'] = 'POST'; - unset($_SERVER['CONTENT_TYPE']); - $route = new Route('/sample', [ - 'controller' => 'posts', - 'action' => 'index', - '_method' => 'POST', - '[type]' => 'application/xml' - ]); - $this->assertFalse($route->parse('/sample'), 'No content type set.'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_SERVER['CONTENT_TYPE'] = 'application/json'; - $this->assertFalse($route->parse('/sample'), 'Wrong content type set.'); - - $_SERVER['REQUEST_METHOD'] = 'POST'; - $_SERVER['CONTENT_TYPE'] = 'application/xml'; - $expected = [ - 'controller' => 'posts', - 'action' => 'index', - 'pass' => [], - '_method' => 'POST', - '[type]' => 'application/xml', - ]; - $this->assertEquals($expected, $route->parse('/sample')); - } - /** * Check [method] compatibility. *