diff options
author | Alex <[email protected]> | 2019-01-29 20:28:52 -0800 |
---|---|---|
committer | Alex <[email protected]> | 2019-01-29 20:28:52 -0800 |
commit | 157e88bcf41426f76b2a599ad7cea70276359920 (patch) | |
tree | 85be92b6a218e330d9c955941cfff918f510a67c /src | |
parent | 55c365f8e8e63a3f4670160d49319dcd434f0fe3 (diff) |
Remove list (bug), create client interface
Diffstat (limited to 'src')
-rw-r--r-- | src/HttpClient.php | 1 | ||||
-rw-r--r-- | src/PSR7Client.php | 38 |
2 files changed, 23 insertions, 16 deletions
diff --git a/src/HttpClient.php b/src/HttpClient.php index 94c70998..b8df83c0 100644 --- a/src/HttpClient.php +++ b/src/HttpClient.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); namespace Spiral\RoadRunner; diff --git a/src/PSR7Client.php b/src/PSR7Client.php index 00261933..3276891b 100644 --- a/src/PSR7Client.php +++ b/src/PSR7Client.php @@ -58,6 +58,14 @@ class PSR7Client } /** + * @return Worker + */ + public function getWorker(): Worker + { + return $this->httpClient->getWorker(); + } + + /** * @return ServerRequestInterface|null */ public function acceptRequest() @@ -66,37 +74,35 @@ class PSR7Client if ($rawRequest === null) return null; - list($ctx, $body) = $rawRequest; - - $_SERVER = $this->configureServer($ctx); + $_SERVER = $this->configureServer($rawRequest['ctx']); $request = $this->requestFactory->createServerRequest( - $ctx['method'], - $ctx['uri'], + $rawRequest['ctx']['method'], + $rawRequest['ctx']['uri'], $_SERVER ); - parse_str($ctx['rawQuery'], $query); + parse_str($rawRequest['ctx']['rawQuery'], $query); $request = $request - ->withProtocolVersion(static::fetchProtocolVersion($ctx['protocol'])) - ->withCookieParams($ctx['cookies']) + ->withProtocolVersion(static::fetchProtocolVersion($rawRequest['ctx']['protocol'])) + ->withCookieParams($rawRequest['ctx']['cookies']) ->withQueryParams($query) - ->withUploadedFiles($this->wrapUploads($ctx['uploads'])); + ->withUploadedFiles($this->wrapUploads($rawRequest['ctx']['uploads'])); - foreach ($ctx['attributes'] as $name => $value) { + foreach ($rawRequest['ctx']['attributes'] as $name => $value) { $request = $request->withAttribute($name, $value); } - foreach ($ctx['headers'] as $name => $value) { + foreach ($rawRequest['ctx']['headers'] as $name => $value) { $request = $request->withHeader($name, $value); } - if ($ctx['parsed']) { - $request = $request->withParsedBody(json_decode($body, true)); + if ($rawRequest['ctx']['parsed']) { + $request = $request->withParsedBody(json_decode($rawRequest['body'], true)); } else { - if ($body !== null) { - $request = $request->withBody($this->streamFactory->createStream($body)); + if ($rawRequest['body'] !== null) { + $request = $request->withBody($this->streamFactory->createStream($rawRequest['body'])); } } @@ -110,7 +116,7 @@ class PSR7Client */ public function respond(ResponseInterface $response) { - $this->httpClient->respond($response->getBody()->__toString(), $response->getStatusCode(), $response->getHeaders()); + $this->httpClient->respond($response->getStatusCode(), $response->getBody()->__toString(), $response->getHeaders()); } /** |