From b21b2007c5ee6050ca29144f3bfbde37fc53e92d Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 9 Jun 2013 11:10:22 -0400 Subject: [PATCH] Guzzle 3.6 conformance Updated inheritance class to match API change Use new Guzzle Header class when searching for values Lock Ratchet into using Guzzle 3.6 to future-proof --- composer.json | 2 +- composer.lock | 30 +++++++++---------- .../Guzzle/Http/Message/RequestFactory.php | 2 +- src/Ratchet/WebSocket/WsServer.php | 7 +++-- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index f83a0b0..92cc54c 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ , "require": { "php": ">=5.3.3" , "react/socket": "0.2.*" - , "guzzle/http": "~3.0" + , "guzzle/http": "3.6.*" , "symfony/http-foundation": "~2.1" } } diff --git a/composer.lock b/composer.lock index 756f447..ca73540 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "9ccce99ef687cb79dad8a4c581f38cc5", + "hash": "b5fee3d5d9c4f60b01030a234d8673f5", "packages": [ { "name": "evenement/evenement", @@ -375,17 +375,17 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.2.1", + "version": "v2.3.0", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { @@ -395,13 +395,13 @@ "symfony/dependency-injection": ">=2.0,<3.0" }, "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -425,21 +425,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-02-11 11:26:43" + "time": "2013-05-13 14:36:40" }, { "name": "symfony/http-foundation", - "version": "v2.2.1", + "version": "v2.3.0", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.2.1" + "reference": "v2.3.0-RC1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.3.0-RC1", + "reference": "v2.3.0-RC1", "shasum": "" }, "require": { @@ -448,7 +448,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -475,7 +475,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-04-06 10:15:43" + "time": "2013-05-10 06:00:03" } ], "packages-dev": [ diff --git a/src/Ratchet/WebSocket/Guzzle/Http/Message/RequestFactory.php b/src/Ratchet/WebSocket/Guzzle/Http/Message/RequestFactory.php index c1f6b45..64b6302 100644 --- a/src/Ratchet/WebSocket/Guzzle/Http/Message/RequestFactory.php +++ b/src/Ratchet/WebSocket/Guzzle/Http/Message/RequestFactory.php @@ -7,7 +7,7 @@ class RequestFactory extends GuzzleRequestFactory { /** * {@inheritdoc} */ - public function create($method, $url, $headers = null, $body = '') { + public function create($method, $url, $headers = null, $body = '', array $options = array()) { $c = $this->entityEnclosingRequestClass; $request = new $c($method, $url, $headers); $request->setBody(EntityBody::factory($body)); diff --git a/src/Ratchet/WebSocket/WsServer.php b/src/Ratchet/WebSocket/WsServer.php index 281f16c..dbc8104 100644 --- a/src/Ratchet/WebSocket/WsServer.php +++ b/src/Ratchet/WebSocket/WsServer.php @@ -117,9 +117,10 @@ class WsServer implements MessageComponentInterface { return; } - // This needs to be refactored later on, incorporated with routing - if ('' !== ($agreedSubProtocols = $this->getSubProtocolString($from->WebSocket->request->getTokenizedHeader('Sec-WebSocket-Protocol', ',')))) { - $response->setHeader('Sec-WebSocket-Protocol', $agreedSubProtocols); + if (null !== ($subHeader = $from->WebSocket->request->getHeader('Sec-WebSocket-Protocol'))) { + if ('' !== ($agreedSubProtocols = $this->getSubProtocolString($subHeader->normalize()))) { + $response->setHeader('Sec-WebSocket-Protocol', $agreedSubProtocols); + } } $response->setHeader('X-Powered-By', \Ratchet\VERSION);