From ba03dc81cfdbb3d25fcc8058e1859658f66c90d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 11 Feb 2021 15:40:43 +0100 Subject: [PATCH] Add HttpFactory::makeClientWithTimeout() --- .../files/lib/system/io/HttpFactory.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wcfsetup/install/files/lib/system/io/HttpFactory.class.php b/wcfsetup/install/files/lib/system/io/HttpFactory.class.php index a2da764c99..7e35ff3405 100644 --- a/wcfsetup/install/files/lib/system/io/HttpFactory.class.php +++ b/wcfsetup/install/files/lib/system/io/HttpFactory.class.php @@ -46,6 +46,20 @@ final class HttpFactory return self::$defaultClient; } + /** + * Creates a new HTTP client with the given $timeout as the maximum + * total transfer duration. + * + * @since 5.4 + * @see HttpFactory::makeClient() + */ + public static function makeClientWithTimeout(float $timeout): ClientInterface + { + return static::makeClient([ + RequestOptions::TIMEOUT => $timeout, + ]); + } + /** * Creates a new HTTP client. * -- 2.20.1