diff --git a/composer.lock b/composer.lock index 8acd009..8b37a34 100644 --- a/composer.lock +++ b/composer.lock @@ -6,20 +6,10 @@ "version": "2.2.x-dev", "source-reference": "1e0aa60d109c630d19543d999f12e2852ef8f932" }, - { - "package": "evenement/evenement", - "version": "dev-master", - "source-reference": "808e3aaea8d4f908e455b0e047cc1acc46b38d44" - }, { "package": "guzzle/guzzle", "version": "v2.4.1" }, - { - "package": "igorw/socket-server", - "version": "dev-master", - "source-reference": "e813968da434ed45219718bc2db29a01174045b6" - }, { "package": "symfony/event-dispatcher", "version": "dev-master", diff --git a/src/Ratchet/Component/WebSocket/Guzzle/Http/Message/RequestFactory.php b/src/Ratchet/Component/WebSocket/Guzzle/Http/Message/RequestFactory.php index 2bc0ab2..fcecde8 100644 --- a/src/Ratchet/Component/WebSocket/Guzzle/Http/Message/RequestFactory.php +++ b/src/Ratchet/Component/WebSocket/Guzzle/Http/Message/RequestFactory.php @@ -4,40 +4,16 @@ use Guzzle\Http\Message\RequestFactory as gReqFac; use Guzzle\Http\Url; /** - * Just slighly changing the Guzzle fromMessage() method to always return an EntityEnclosingRequest instance instead of Request + * Just slighly changing the Guzzle RequestFactory to always return an EntityEnclosingRequest instance instead of Request */ class RequestFactory extends gReqFac { - /** - * @param string - * @return Guzzle\Http\Message\RequestInterface - */ - public static function fromRequest($message) { - $parsed = static::parseMessage($message); - - if (!$parsed) { - return false; + public static function getInstance() { + static $instance = null; + if (null === $instance) { + $instance = parent::getInstance(); + static::$instance->requestClass = static::$instance->entityEnclosingRequestClass; } - return self::fromRequestParts( - $parsed['method'], - $parsed['parts'], - $parsed['headers'], - $parsed['body'], - $parsed['protocol'], - $parsed['protocol_version'] - ); - } - - protected static function fromRequestParts($method, array $parts, $headers = null, $body = null, $protocol = 'HTTP', $protocolVersion = '1.1') { - return self::requestCreate($method, Url::buildUrl($parts, true), $headers, $body) - ->setProtocolVersion($protocolVersion); - } - - protected static function requestCreate($method, $url, $headers = null, $body = null) { - $c = static::$entityEnclosingRequestClass; - $request = new $c($method, $url, $headers); - $request->setBody($body); - - return $request; + return $instance; } } \ No newline at end of file diff --git a/src/Ratchet/Component/WebSocket/WebSocketComponent.php b/src/Ratchet/Component/WebSocket/WebSocketComponent.php index c85b28a..24b4b7c 100644 --- a/src/Ratchet/Component/WebSocket/WebSocketComponent.php +++ b/src/Ratchet/Component/WebSocket/WebSocketComponent.php @@ -72,7 +72,7 @@ class WebSocketComponent implements MessageComponentInterface { return; } - $headers = RequestFactory::fromRequest($from->WebSocket->headers); + $headers = RequestFactory::getInstance()->fromMessage($from->WebSocket->headers); $from->WebSocket->version = $this->getVersion($headers); $from->WebSocket->headers = $headers; }