From f39d989acf283f7fadc800ab07826954f1d75ead Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Thu, 23 Feb 2017 22:51:19 +0100 Subject: [PATCH] Fixes erroneous response returned by sendRequest and waitForResponse methods, see #1 --- CHANGELOG.md | 11 +++++++++++ README.md | 41 +++++++++++++++++++++++++++++++++++++++++ src/Client.php | 15 +++++++++------ 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 822194f..eaf09b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com). +## [1.0.1] - 2017-02-23 + +### Fixed + +* Erroneous response returned by `Client::sendRequest()` and `Client::waitForResponse()` - [#1](https://github.com/hollodotme/fast-cgi-client/issues/1) + +### Changed + +* Testsuite updated for PHPUnit >= 6 + ## [1.0.0] - 2017-01-03 Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](https://github.com/adoy/PHP-FastCGI-Client/): @@ -27,4 +37,5 @@ Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](http * Getters/Setters for connect timeout, read/write timeout, keep alive, socket persistence from `Client` (now part of the socket connection) * Method `Client->getValues()` +[1.0.1]: https://github.com/hollodotme/fast-cgi-client/compare/v1.0.0...v1.0.1 [1.0.0]: https://github.com/hollodotme/fast-cgi-client/tree/v1.0.0 diff --git a/README.md b/README.md index d0a7e4e..2e8d876 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,47 @@ $response = $client->waitForResponse( ); ``` +### Responses + +Assuming `/path/to/target/script.php` has the following content: + +```php +socket, $response['paddingLength'] ); + fread( $this->socket, $response['paddingLength'] ); } return $response; @@ -211,11 +211,13 @@ public function sendRequest( array $params, string $content ) : string * In that case it is possible that a delayed response to a request made by a previous script * invocation comes back on this socket and is mistaken for response to request made with same ID * during this request. - * - * @param array $params Array of parameters + +* +* @param array $params Array of parameters * @param string $content Content - * -*@throws TimedoutException + +* +* @throws TimedoutException * @throws WriteFailedException * @return int */ @@ -347,7 +349,8 @@ public function waitForResponse( int $requestId, int $timeoutMs = 0 ) : string throw new TimedoutException( 'Timed out' ); } - } while ( $packet ); + } + while ( null !== $packet ); if ( $packet === null ) {