diff options
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rwxr-xr-x | build.sh | 2 | ||||
-rw-r--r-- | src/HttpClient.php | 8 | ||||
-rw-r--r-- | src/PSR7Client.php | 20 |
4 files changed, 22 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b81224..340bc31e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ CHANGELOG ========= +v1.3.3 (31.01.2019) +------------------- +- added HttpClient for faster integrations with non PSR-7 frameworks + v1.3.2 (11.01.2019) ------------------- -- `_SERVER` now exposes headers with HTTP_ prefix (fixing Laravel integration) by @Alex-Bond +- `_SERVER` now exposes headers with HTTP_ prefix (fixing Lravel integration) by @Alex-Bond - fixed bug causing body payload not being received for custom HTTP methods by @Alex-Bond v1.3.1 (11.01.2019) @@ -2,7 +2,7 @@ cd $(dirname "${BASH_SOURCE[0]}") OD="$(pwd)" # Pushes application version into the build information. -RR_VERSION=1.3.2 +RR_VERSION=1.3.3 # Hardcode some values to the core package LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${RR_VERSION}" 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); |