Merge branch 'master' into 0.4

# Conflicts:
#	CHANGELOG.md
#	src/Ratchet/ConnectionInterface.php
#	src/Ratchet/Http/Router.php
#	src/Ratchet/WebSocket/Version/RFC6455.php
#	tests/unit/Http/RouterTest.php
This commit is contained in:
Chris Boden 2017-02-16 20:14:25 -05:00
commit 4cf38fe82e
8 changed files with 37 additions and 7 deletions

View File

@ -4,7 +4,8 @@ php:
- 5.4 - 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- 7 - 7.0
- 7.1
- hhvm - hhvm
before_script: before_script:

View File

@ -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 * BC: $conn->WebSocket->request replaced with $conn->httpRequest which is a PSR-7 object
* Binary messages now supported via Ratchet\WebSocket\MessageComponentInterface * Binary messages now supported via Ratchet\WebSocket\MessageComponentInterface
@ -19,6 +19,15 @@ CHANGELOG
* BC: PHP 5.3 no longer supported * BC: PHP 5.3 no longer supported
* Significant performance enhancements * 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) * 0.3.4 (2015-12-23)
* BF: Edge case where version check wasn't run on message coalesce * BF: Edge case where version check wasn't run on message coalesce

View File

@ -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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -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; return $decorated;
} }

View File

@ -37,7 +37,7 @@ class Router implements HttpServerInterface {
try { try {
$route = $this->_matcher->match($uri->getPath()); $route = $this->_matcher->match($uri->getPath());
} catch (MethodNotAllowedException $nae) { } catch (MethodNotAllowedException $nae) {
return $this->close($conn, 403); return $this->close($conn, 405, array('Allow' => $nae->getAllowedMethods()));
} catch (ResourceNotFoundException $nfe) { } catch (ResourceNotFoundException $nfe) {
return $this->close($conn, 404); return $this->close($conn, 404);
} }

View File

@ -3,10 +3,21 @@ namespace Ratchet\Session\Serialize;
class PhpHandler implements HandlerInterface { class PhpHandler implements HandlerInterface {
/** /**
* Simply reverse behaviour of unserialize method.
* {@inheritdoc} * {@inheritdoc}
*/ */
function serialize(array $data) { 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;
} }
/** /**

View File

@ -139,5 +139,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase {
$router->onOpen($conn, $request); $router->onOpen($conn, $request);
$this->assertEquals('foo=nope&baz=qux&hello=world', $request->getUri()->getQuery()); $this->assertEquals('foo=nope&baz=qux&hello=world', $request->getUri()->getQuery());
$this->assertEquals('ws', $request->getUri()->getScheme());
$this->assertEquals('doesnt.matter', $request->getUri()->getHost());
} }
} }

View File

@ -33,4 +33,11 @@ class PhpHandlerTest extends \PHPUnit_Framework_TestCase {
public function testUnserialize($in, $expected) { public function testUnserialize($in, $expected) {
$this->assertEquals($expected, $this->_handler->unserialize($in)); $this->assertEquals($expected, $this->_handler->unserialize($in));
} }
/**
* @dataProvider serializedProvider
*/
public function testSerialize($serialized, $original) {
$this->assertEquals($serialized, $this->_handler->serialize($original));
}
} }