summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-01-31 15:11:53 +0300
committerWolfy-J <[email protected]>2019-01-31 15:11:53 +0300
commit2b33bfc836134ca11fd5d095e1a98899265548fc (patch)
treeac7cd94644bae416ebfe7f8438c3aa44117e6ed3 /src
parent22f01fa5627d11f00652310abbddd7ba03947771 (diff)
- added HttpClient for raw message consuming
Diffstat (limited to 'src')
-rw-r--r--src/HttpClient.php8
-rw-r--r--src/PSR7Client.php20
2 files changed, 16 insertions, 12 deletions
diff --git a/src/HttpClient.php b/src/HttpClient.php
index 70b46ef5..34ae0e77 100644
--- a/src/HttpClient.php
+++ b/src/HttpClient.php
@@ -46,11 +46,11 @@ class HttpClient
/**
* Send response to the application server.
*
- * @param int $status Http status code
- * @param string $body Body of response
+ * @param int $status Http status code
+ * @param string $body Body of response
* @param string[][] $headers An associative array of the message's headers. Each
- * key MUST be a header name, and each value MUST be an array of strings
- * for that header.
+ * key MUST be a header name, and each value MUST be an array of strings
+ * for that header.
*/
public function respond(int $status, string $body, $headers = [])
{
diff --git a/src/PSR7Client.php b/src/PSR7Client.php
index 3276891b..a18d1754 100644
--- a/src/PSR7Client.php
+++ b/src/PSR7Client.php
@@ -38,18 +38,17 @@ class PSR7Client
private static $allowedVersions = ['1.0', '1.1', '2',];
/**
- * @param Worker $worker
+ * @param Worker $worker
* @param ServerRequestFactoryInterface|null $requestFactory
- * @param StreamFactoryInterface|null $streamFactory
- * @param UploadedFileFactoryInterface|null $uploadsFactory
+ * @param StreamFactoryInterface|null $streamFactory
+ * @param UploadedFileFactoryInterface|null $uploadsFactory
*/
public function __construct(
Worker $worker,
ServerRequestFactoryInterface $requestFactory = null,
StreamFactoryInterface $streamFactory = null,
UploadedFileFactoryInterface $uploadsFactory = null
- )
- {
+ ) {
$this->httpClient = new HttpClient($worker);
$this->requestFactory = $requestFactory ?? new Diactoros\ServerRequestFactory();
$this->streamFactory = $streamFactory ?? new Diactoros\StreamFactory();
@@ -71,8 +70,9 @@ class PSR7Client
public function acceptRequest()
{
$rawRequest = $this->httpClient->acceptRequest();
- if ($rawRequest === null)
+ if ($rawRequest === null) {
return null;
+ }
$_SERVER = $this->configureServer($rawRequest['ctx']);
@@ -116,7 +116,11 @@ class PSR7Client
*/
public function respond(ResponseInterface $response)
{
- $this->httpClient->respond($response->getStatusCode(), $response->getBody()->__toString(), $response->getHeaders());
+ $this->httpClient->respond(
+ $response->getStatusCode(),
+ $response->getBody()->__toString(),
+ $response->getHeaders()
+ );
}
/**
@@ -137,7 +141,7 @@ class PSR7Client
$server['HTTP_USER_AGENT'] = '';
foreach ($ctx['headers'] as $key => $value) {
$key = strtoupper(str_replace('-', '_', $key));
- if (\in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
+ if (\in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH'])) {
$server[$key] = implode(', ', $value);
} else {
$server['HTTP_' . $key] = implode(', ', $value);