From 5eb1dfa98db73f7b6c40abf705c19ba472f9f369 Mon Sep 17 00:00:00 2001 From: samizdam Date: Thu, 10 Nov 2016 21:05:00 +0300 Subject: [PATCH 1/3] Use 403 status code on MethodNotAllowedException. --- src/Ratchet/Http/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ratchet/Http/Router.php b/src/Ratchet/Http/Router.php index bfc8193..2cfc5bf 100644 --- a/src/Ratchet/Http/Router.php +++ b/src/Ratchet/Http/Router.php @@ -34,7 +34,7 @@ class Router implements HttpServerInterface { try { $route = $this->_matcher->match($request->getPath()); } catch (MethodNotAllowedException $nae) { - return $this->close($conn, 403); + return $this->close($conn, 405); } catch (ResourceNotFoundException $nfe) { return $this->close($conn, 404); } From 7215ffe9e630978b73fe5d9f9bba47b29b14334b Mon Sep 17 00:00:00 2001 From: samizdam Date: Thu, 17 Nov 2016 19:42:22 +0300 Subject: [PATCH 2/3] Send additional headers on close connection in Router. --- src/Ratchet/Http/Router.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Ratchet/Http/Router.php b/src/Ratchet/Http/Router.php index 2cfc5bf..e4aa790 100644 --- a/src/Ratchet/Http/Router.php +++ b/src/Ratchet/Http/Router.php @@ -34,7 +34,7 @@ class Router implements HttpServerInterface { try { $route = $this->_matcher->match($request->getPath()); } catch (MethodNotAllowedException $nae) { - return $this->close($conn, 405); + return $this->close($conn, 405, array('Allow' => $nae->getAllowedMethods())); } catch (ResourceNotFoundException $nfe) { return $this->close($conn, 404); } @@ -91,13 +91,15 @@ class Router implements HttpServerInterface { /** * Close a connection with an HTTP response * @param \Ratchet\ConnectionInterface $conn - * @param int $code HTTP status code + * @param int $code HTTP status code + * @param array $additionalHeaders * @return null */ - protected function close(ConnectionInterface $conn, $code = 400) { - $response = new Response($code, array( + protected function close(ConnectionInterface $conn, $code = 400, array $additionalHeaders = array()) { + $headers = array_merge(array( 'X-Powered-By' => \Ratchet\VERSION - )); + ), $additionalHeaders); + $response = new Response($code, $headers); $conn->send((string)$response); $conn->close(); From 64bc5822c80ce6c16d5033fa63eb10c997cd30f9 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Fri, 30 Dec 2016 13:26:04 -0500 Subject: [PATCH 3/3] Set GET required in Symfony Route --- src/Ratchet/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ratchet/App.php b/src/Ratchet/App.php index b7d0e55..c52a2c7 100644 --- a/src/Ratchet/App.php +++ b/src/Ratchet/App.php @@ -132,7 +132,7 @@ class App { } } - $this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, array('_controller' => $decorated), array('Origin' => $this->httpHost), array(), $httpHost)); + $this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, array('_controller' => $decorated), array('Origin' => $this->httpHost), array(), $httpHost, array(), array('GET'))); return $decorated; }