diff --git a/.travis.yml b/.travis.yml index 927d1d7..7fe84a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,8 @@ php: - 5.4 - 5.5 - 5.6 - - 7 + - 7.0 + - 7.1 - hhvm before_script: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d65ad0..821414f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ CHANGELOG --- -* 0.4 (2016-) +* 0.4 (2017-) * BC: $conn->WebSocket->request replaced with $conn->httpRequest which is a PSR-7 object * Binary messages now supported via Ratchet\WebSocket\MessageComponentInterface @@ -19,6 +19,15 @@ CHANGELOG * BC: PHP 5.3 no longer supported * Significant performance enhancements +* 0.3.6 (2017-01-06) + * BF: Keep host and scheme in HTTP request object attatched to connection + * BF: Return correct HTTP response (405) when non-GET request made + +* 0.3.5 (2016-05-25) + + * BF: Unmask responding close frame + * Added write handler for PHP session serializer + * 0.3.4 (2015-12-23) * BF: Edge case where version check wasn't run on message coalesce diff --git a/LICENSE b/LICENSE index 7f8c128..24abba1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2016 Chris Boden +Copyright (c) 2011-2017 Chris Boden Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Ratchet/App.php b/src/Ratchet/App.php index da144ec..1216242 100644 --- a/src/Ratchet/App.php +++ b/src/Ratchet/App.php @@ -136,7 +136,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; } diff --git a/src/Ratchet/Http/Router.php b/src/Ratchet/Http/Router.php index 8931b6e..06515c4 100644 --- a/src/Ratchet/Http/Router.php +++ b/src/Ratchet/Http/Router.php @@ -37,7 +37,7 @@ class Router implements HttpServerInterface { try { $route = $this->_matcher->match($uri->getPath()); } catch (MethodNotAllowedException $nae) { - return $this->close($conn, 403); + return $this->close($conn, 405, array('Allow' => $nae->getAllowedMethods())); } catch (ResourceNotFoundException $nfe) { return $this->close($conn, 404); } @@ -88,4 +88,4 @@ class Router implements HttpServerInterface { $conn->controller->onError($conn, $e); } } -} \ No newline at end of file +} diff --git a/src/Ratchet/Session/Serialize/PhpHandler.php b/src/Ratchet/Session/Serialize/PhpHandler.php index 8fb5308..b1df356 100644 --- a/src/Ratchet/Session/Serialize/PhpHandler.php +++ b/src/Ratchet/Session/Serialize/PhpHandler.php @@ -3,10 +3,21 @@ namespace Ratchet\Session\Serialize; class PhpHandler implements HandlerInterface { /** + * Simply reverse behaviour of unserialize method. * {@inheritdoc} */ function serialize(array $data) { - throw new \RuntimeException("Serialize PhpHandler:serialize code not written yet, write me!"); + $preSerialized = array(); + $serialized = ''; + + if (count($data)) { + foreach ($data as $bucket => $bucketData) { + $preSerialized[] = $bucket . '|' . serialize($bucketData); + } + $serialized = implode('', $preSerialized); + } + + return $serialized; } /** diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 0799519..e924aa1 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -139,5 +139,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase { $router->onOpen($conn, $request); $this->assertEquals('foo=nope&baz=qux&hello=world', $request->getUri()->getQuery()); + $this->assertEquals('ws', $request->getUri()->getScheme()); + $this->assertEquals('doesnt.matter', $request->getUri()->getHost()); } } diff --git a/tests/unit/Session/Serialize/PhpHandlerTest.php b/tests/unit/Session/Serialize/PhpHandlerTest.php index 4dddee9..4acf5bc 100644 --- a/tests/unit/Session/Serialize/PhpHandlerTest.php +++ b/tests/unit/Session/Serialize/PhpHandlerTest.php @@ -33,4 +33,11 @@ class PhpHandlerTest extends \PHPUnit_Framework_TestCase { public function testUnserialize($in, $expected) { $this->assertEquals($expected, $this->_handler->unserialize($in)); } + + /** + * @dataProvider serializedProvider + */ + public function testSerialize($serialized, $original) { + $this->assertEquals($serialized, $this->_handler->serialize($original)); + } }