diff --git a/.travis.yml b/.travis.yml index 8b584a9..deadd3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,9 @@ cache: - $HOME/.composer/cache php: - - 7.1 - 7.2 - 7.3 + - 7.4 env: global: @@ -22,18 +22,13 @@ branches: matrix: fast_finish: true include: - - php: 7.1 + - php: 7.2 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" - php: 7.2 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" - - php: 7.3 - env: USE_ASYNC=true before_install: - travis_retry composer self-update - - if [[ "$USE_ASYNC" = true ]]; then git clone https://github.com/concurrent-php/ext-async.git /tmp/async; fi - - if [[ "$USE_ASYNC" = true ]]; then cd /tmp/async && phpize && ./configure && sudo make install; fi - - if [[ "$USE_ASYNC" = true ]]; then echo "extension = async.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini && php -m && cd $TRAVIS_BUILD_DIR; fi install: - travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction --ignore-platform-reqs @@ -44,7 +39,6 @@ before_script: script: - cd ./tests/server/ssl && ./generate.sh && pwd && ls -la && cd ../../../ - $TEST_COMMAND - - ./vendor/bin/phpunit tests/SocketClientFeatureTest.php --printer Http\\Client\\Tests\\FeatureTestListener || echo "" after_success: - if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi diff --git a/CHANGELOG.md b/CHANGELOG.md index f92a44d..b4ec355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## 2.0.0 (unreleased) +## 2.0.0 * Remove response and stream factory, use direct implementation of nyholm/psr7 * Async support with ext-async extension: see https://github.com/concurrent-php/ext-async @@ -20,7 +20,7 @@ * `ConnectionException` * `InvalidRequestException` * `SSLConnectionException` - + ## 1.2.0 * Dropped PHP 5.4 support diff --git a/composer.json b/composer.json index 6a7dbdd..178985f 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,14 @@ "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0 || ^5.0" }, "require-dev": { - "concurrent-php/async-api": "dev-master", "friendsofphp/php-cs-fixer": "^2.2", "php-http/client-integration-tests": "dev-master", "php-http/message": "^1.0", "php-http/client-common": "^2.0" }, "provide": { - "php-http/client-implementation": "1.0" + "php-http/client-implementation": "1.0", + "psr/http-client": "1.0" }, "autoload": { "psr-4": { diff --git a/src/Client.php b/src/Client.php index 9c5a3d6..9480549 100644 --- a/src/Client.php +++ b/src/Client.php @@ -34,8 +34,6 @@ class Client implements HttpClient 'ssl_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, ]; - private $hasAsync; - /** * Constructor. * @@ -52,8 +50,6 @@ class Client implements HttpClient */ public function __construct($config1 = [], $config2 = null, array $config = []) { - $this->hasAsync = PHP_VERSION_ID >= 70300 && \extension_loaded('async'); - if (\is_array($config1)) { $this->config = $this->configure($config1); @@ -171,7 +167,6 @@ protected function configure(array $config = []) /** * Return remote socket from the request. * - * * @throws InvalidRequestException When no remote can be determined from the request * * @return string @@ -191,10 +186,6 @@ private function determineRemoteFromRequest(RequestInterface $request) $endpoint = $request->getHeaderLine('Host'); } - if ($this->hasAsync) { - return sprintf('async-tcp://%s', $endpoint); - } - return sprintf('tcp://%s', $endpoint); } } diff --git a/tests/AsyncTest.php b/tests/AsyncTest.php deleted file mode 100644 index 58f62d8..0000000 --- a/tests/AsyncTest.php +++ /dev/null @@ -1,37 +0,0 @@ -markTestSkipped('Test need async extension'); - } - - $client = new Client(); - $request = new Request('GET', 'https://httpbin.org/delay/1'); - - $timeStart = microtime(true); - $task1 = Task::async(function () use ($request, $client) { - return $client->sendRequest($request); - }); - $task2 = Task::async(function () use ($request, $client) { - return $client->sendRequest($request); - }); - - [$response1, $response2] = Task::await(all([$task1, $task2])); - $timeTaken = microtime(true) - $timeStart; - - self::assertLessThan(2, $timeTaken); - self::assertEquals(200, $response1->getStatusCode()); - self::assertEquals(200, $response2->getStatusCode()); - } -} diff --git a/tests/SocketClientFeatureTest.php b/tests/SocketClientFeatureTest.php index aa614c4..e6e698b 100644 --- a/tests/SocketClientFeatureTest.php +++ b/tests/SocketClientFeatureTest.php @@ -2,8 +2,8 @@ namespace Http\Client\Socket\Tests; -use Http\Client\Tests\HttpFeatureTest; use Http\Client\Socket\Client as SocketHttpClient; +use Http\Client\Tests\HttpFeatureTest; use Psr\Http\Client\ClientInterface; class SocketClientFeatureTest extends HttpFeatureTest diff --git a/tests/SocketHttpAdapterTest.php b/tests/SocketHttpAdapterTest.php index 7aa785b..f95b28e 100644 --- a/tests/SocketHttpAdapterTest.php +++ b/tests/SocketHttpAdapterTest.php @@ -2,8 +2,8 @@ namespace Http\Client\Socket\Tests; -use Http\Client\Tests\HttpClientTest; use Http\Client\Socket\Client as SocketHttpClient; +use Http\Client\Tests\HttpClientTest; use Psr\Http\Client\ClientInterface; class SocketHttpAdapterTest extends HttpClientTest diff --git a/tests/SocketHttpClientTest.php b/tests/SocketHttpClientTest.php index cfec8ce..cca4fd6 100644 --- a/tests/SocketHttpClientTest.php +++ b/tests/SocketHttpClientTest.php @@ -3,8 +3,8 @@ namespace Http\Client\Socket\Tests; use Http\Client\Common\HttpMethodsClient; -use Http\Message\MessageFactory\GuzzleMessageFactory; use Http\Client\Socket\Client as SocketHttpClient; +use Http\Message\MessageFactory\GuzzleMessageFactory; class SocketHttpClientTest extends BaseTestCase {