diff --git a/composer.json b/composer.json index 51edc74..2f2c7be 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "ext-json": "*", "codeception/codeception": "*@dev", "codeception/lib-innerbrowser": "*@dev", - "guzzlehttp/guzzle": "^7.4", + "guzzlehttp/guzzle": "^7.8.2 | ^8.0", + "guzzlehttp/psr7": "^2.6.3 | ^3.0", "symfony/browser-kit": "^5.4 | ^6.0 | ^7.0 | ^8.0" }, "require-dev": { diff --git a/src/Codeception/Lib/Connector/Guzzle.php b/src/Codeception/Lib/Connector/Guzzle.php index 9888276..7687695 100644 --- a/src/Codeception/Lib/Connector/Guzzle.php +++ b/src/Codeception/Lib/Connector/Guzzle.php @@ -209,11 +209,13 @@ protected function doRequest(object $request): object $response = $this->client->send($guzzleRequest, $options); } } catch (RequestException $exception) { - if (!$exception->hasResponse()) { + // Guzzle 7 exposes the response on RequestException itself, + // Guzzle 8 only on its ResponseException subclass. + $response = method_exists($exception, 'getResponse') ? $exception->getResponse() : null; + + if ($response === null) { throw $exception; } - - $response = $exception->getResponse(); } // @phpstan-ignore-next-line diff --git a/src/Codeception/Module/PhpBrowser.php b/src/Codeception/Module/PhpBrowser.php index b8ce650..15e4631 100644 --- a/src/Codeception/Module/PhpBrowser.php +++ b/src/Codeception/Module/PhpBrowser.php @@ -44,7 +44,7 @@ * url: 'http://localhost' # Internationalized domain names (IDN) need to be passed in punycode * auth: ['admin', '123345'] * curl: - * CURLOPT_RETURNTRANSFER: true + * CURLOPT_TCP_KEEPALIVE: true * cookies: * cookie-1: * Name: userName diff --git a/tests/unit/Codeception/Module/PhpBrowserTest.php b/tests/unit/Codeception/Module/PhpBrowserTest.php index 2fd2c85..2db737b 100644 --- a/tests/unit/Codeception/Module/PhpBrowserTest.php +++ b/tests/unit/Codeception/Module/PhpBrowserTest.php @@ -397,7 +397,6 @@ public function testCurlSslOptions(): void $this->module->_setConfig([ 'url' => 'https://github.com', 'curl' => [ - 'CURLOPT_NOBODY' => true, 'CURLOPT_SSL_CIPHER_LIST' => 'TLSv1', ]]); $this->module->_initialize(); @@ -407,7 +406,7 @@ public function testCurlSslOptions(): void $this->assertArrayHasKey('curl', $config); $this->assertArrayHasKey(CURLOPT_SSL_CIPHER_LIST, $config['curl']); $this->module->amOnPage('/'); - $this->assertSame('', $this->module->_getResponseContent(), 'CURLOPT_NOBODY setting is not respected'); + $this->module->seeResponseCodeIsSuccessful(); } public function testHttpAuth(): void