Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PSR7 2.x #922

Merged
merged 1 commit into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"php": ">=5.4.2"
, "ratchet/rfc6455": "^0.3"
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5"
, "guzzlehttp/psr7": "^1.0"
, "guzzlehttp/psr7": "^1.7|^2.0"
, "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0"
, "symfony/routing": "^2.6|^3.0|^4.0|^5.0"
}
Expand Down
6 changes: 3 additions & 3 deletions src/Ratchet/Http/CloseResponseTrait.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Ratchet\Http;
use Ratchet\ConnectionInterface;
use GuzzleHttp\Psr7 as gPsr;
use GuzzleHttp\Psr7\Message;
use GuzzleHttp\Psr7\Response;

trait CloseResponseTrait {
Expand All @@ -16,7 +16,7 @@ private function close(ConnectionInterface $conn, $code = 400, array $additional
'X-Powered-By' => \Ratchet\VERSION
], $additional_headers));

$conn->send(gPsr\str($response));
$conn->send(Message::toString($response));
$conn->close();
}
}
}
4 changes: 2 additions & 2 deletions src/Ratchet/Http/HttpRequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace Ratchet\Http;
use Ratchet\MessageInterface;
use Ratchet\ConnectionInterface;
use GuzzleHttp\Psr7 as gPsr;
use GuzzleHttp\Psr7\Message;

/**
* This class receives streaming data from a client request
Expand Down Expand Up @@ -59,6 +59,6 @@ public function isEom($message) {
* @return \Psr\Http\Message\RequestInterface
*/
public function parse($headers) {
return gPsr\parse_request($headers);
return Message::parseRequest($headers);
}
}
6 changes: 3 additions & 3 deletions src/Ratchet/Http/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use GuzzleHttp\Psr7 as gPsr;
use GuzzleHttp\Psr7\Query;

class Router implements HttpServerInterface {
use CloseResponseTrait;
Expand Down Expand Up @@ -61,9 +61,9 @@ public function onOpen(ConnectionInterface $conn, RequestInterface $request = nu
$parameters[$key] = $value;
}
}
$parameters = array_merge($parameters, gPsr\parse_query($uri->getQuery() ?: ''));
$parameters = array_merge($parameters, Query::parse($uri->getQuery() ?: ''));

$request = $request->withUri($uri->withQuery(gPsr\build_query($parameters)));
$request = $request->withUri($uri->withQuery(Query::build($parameters)));

$conn->controller = $route['_controller'];
$conn->controller->onOpen($conn, $request);
Expand Down
4 changes: 2 additions & 2 deletions src/Ratchet/WebSocket/WsServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Ratchet\RFC6455\Handshake\ServerNegotiator;
use Ratchet\RFC6455\Handshake\RequestVerifier;
use React\EventLoop\LoopInterface;
use GuzzleHttp\Psr7 as gPsr;
use GuzzleHttp\Psr7\Message;

/**
* The adapter to handle WebSocket requests/responses
Expand Down Expand Up @@ -116,7 +116,7 @@ public function onOpen(ConnectionInterface $conn, RequestInterface $request = nu

$response = $this->handshakeNegotiator->handshake($request)->withHeader('X-Powered-By', \Ratchet\VERSION);

$conn->send(gPsr\str($response));
$conn->send(Message::toString($response));

if (101 !== $response->getStatusCode()) {
return $conn->close();
Expand Down