From c690802618b9b0f09e3d48286887575f63352c32 Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Mon, 26 Sep 2022 11:12:06 +0200 Subject: [PATCH 1/3] Sync `connect_timeout` values around the code and docs --- docs/request-options.rst | 2 +- src/Handler/CurlFactory.php | 2 +- src/RequestOptions.php | 2 +- tests/Handler/CurlFactoryTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/request-options.rst b/docs/request-options.rst index a4407030d..f155eee96 100644 --- a/docs/request-options.rst +++ b/docs/request-options.rst @@ -282,7 +282,7 @@ connect_timeout --------------- :Summary: Float describing the number of seconds to wait while trying to connect - to a server. Use ``0`` to wait indefinitely (the default behavior). + to a server. Use ``0`` to wait 300 seconds (the default behavior). :Types: float :Default: ``0`` :Constant: ``GuzzleHttp\RequestOptions::CONNECT_TIMEOUT`` diff --git a/src/Handler/CurlFactory.php b/src/Handler/CurlFactory.php index 0c45089f1..211473402 100644 --- a/src/Handler/CurlFactory.php +++ b/src/Handler/CurlFactory.php @@ -224,7 +224,7 @@ private function getDefaultConf(EasyHandle $easy): array \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => false, \CURLOPT_HEADER => false, - \CURLOPT_CONNECTTIMEOUT => 150, + \CURLOPT_CONNECTTIMEOUT_MS => 300000, ]; if (\defined('CURLOPT_PROTOCOLS')) { diff --git a/src/RequestOptions.php b/src/RequestOptions.php index 20b31bc20..05d918a23 100644 --- a/src/RequestOptions.php +++ b/src/RequestOptions.php @@ -70,7 +70,7 @@ final class RequestOptions /** * connect_timeout: (float, default=0) Float describing the number of * seconds to wait while trying to connect to a server. Use 0 to wait - * indefinitely (the default behavior). + * 300 seconds (the default behavior). */ public const CONNECT_TIMEOUT = 'connect_timeout'; diff --git a/tests/Handler/CurlFactoryTest.php b/tests/Handler/CurlFactoryTest.php index 254d7c188..96e4646ab 100644 --- a/tests/Handler/CurlFactoryTest.php +++ b/tests/Handler/CurlFactoryTest.php @@ -66,7 +66,7 @@ public function testCreatesCurlHandle() self::assertSame('testing', $_SERVER['_curl'][\CURLOPT_POSTFIELDS]); self::assertEquals(0, $_SERVER['_curl'][\CURLOPT_RETURNTRANSFER]); self::assertEquals(0, $_SERVER['_curl'][\CURLOPT_HEADER]); - self::assertSame(150, $_SERVER['_curl'][\CURLOPT_CONNECTTIMEOUT]); + self::assertSame(300000, $_SERVER['_curl'][\CURLOPT_CONNECTTIMEOUT_MS]); self::assertInstanceOf('Closure', $_SERVER['_curl'][\CURLOPT_HEADERFUNCTION]); if (\defined('CURLOPT_PROTOCOLS')) { self::assertSame( From 0dcb6224fcaf258028af4f2bd37e3483b7f737b8 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 14 May 2023 11:14:35 +0200 Subject: [PATCH 2/3] Avoid BC break for people overriding this config --- src/Handler/CurlFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handler/CurlFactory.php b/src/Handler/CurlFactory.php index 211473402..8d547ed20 100644 --- a/src/Handler/CurlFactory.php +++ b/src/Handler/CurlFactory.php @@ -224,7 +224,7 @@ private function getDefaultConf(EasyHandle $easy): array \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => false, \CURLOPT_HEADER => false, - \CURLOPT_CONNECTTIMEOUT_MS => 300000, + \CURLOPT_CONNECTTIMEOUT => 300, ]; if (\defined('CURLOPT_PROTOCOLS')) { From 5c7232da6e9c5fcbc156531946c8c364b1900eed Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 14 May 2023 11:15:08 +0200 Subject: [PATCH 3/3] Update CurlFactoryTest.php --- tests/Handler/CurlFactoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Handler/CurlFactoryTest.php b/tests/Handler/CurlFactoryTest.php index 96e4646ab..3e996274f 100644 --- a/tests/Handler/CurlFactoryTest.php +++ b/tests/Handler/CurlFactoryTest.php @@ -66,7 +66,7 @@ public function testCreatesCurlHandle() self::assertSame('testing', $_SERVER['_curl'][\CURLOPT_POSTFIELDS]); self::assertEquals(0, $_SERVER['_curl'][\CURLOPT_RETURNTRANSFER]); self::assertEquals(0, $_SERVER['_curl'][\CURLOPT_HEADER]); - self::assertSame(300000, $_SERVER['_curl'][\CURLOPT_CONNECTTIMEOUT_MS]); + self::assertSame(300, $_SERVER['_curl'][\CURLOPT_CONNECTTIMEOUT]); self::assertInstanceOf('Closure', $_SERVER['_curl'][\CURLOPT_HEADERFUNCTION]); if (\defined('CURLOPT_PROTOCOLS')) { self::assertSame(