]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat(http-client): expose default request timeout constant to be used instead of... add-default-request-timeout-const 48639/head
authorThomas Citharel <tcit@tcit.fr>
Thu, 10 Oct 2024 05:54:46 +0000 (07:54 +0200)
committerThomas Citharel <tcit@tcit.fr>
Fri, 11 Oct 2024 08:57:02 +0000 (10:57 +0200)
Will be used to set default where we are able to override the default timeout.

See https://github.com/nextcloud/server/pull/48418

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
lib/private/Files/Storage/DAV.php
lib/private/Http/Client/Client.php
lib/public/Http/Client/IClient.php

index e310e4357f1daab8905f7ef8db1764a814bbc0a7..e0f7700415fe1e7ebbf00fa80657f4a8a2978a56 100644 (file)
@@ -20,6 +20,7 @@ use OCP\Files\ForbiddenException;
 use OCP\Files\IMimeTypeDetector;
 use OCP\Files\StorageInvalidException;
 use OCP\Files\StorageNotAvailableException;
+use OCP\Http\Client\IClient;
 use OCP\Http\Client\IClientService;
 use OCP\ICertificateManager;
 use OCP\IConfig;
@@ -124,7 +125,7 @@ class DAV extends Common {
                $this->logger = Server::get(LoggerInterface::class);
                $this->eventLogger = Server::get(IEventLogger::class);
                // This timeout value will be used for the download and upload of files
-               $this->timeout = Server::get(IConfig::class)->getSystemValueInt('davstorage.request_timeout', 30);
+               $this->timeout = Server::get(IConfig::class)->getSystemValueInt('davstorage.request_timeout', IClient::DEFAULT_REQUEST_TIMEOUT);
                $this->mimeTypeDetector = \OC::$server->getMimeTypeDetector();
        }
 
index 62209ff9040d12403310871ca61bd1373ec61f3c..c3f8f58982734f8ffca55c5b9fedbe330d1e658d 100644 (file)
@@ -53,7 +53,7 @@ class Client implements IClient {
 
                $defaults = [
                        RequestOptions::VERIFY => $this->getCertBundle(),
-                       RequestOptions::TIMEOUT => 30,
+                       RequestOptions::TIMEOUT => IClient::DEFAULT_REQUEST_TIMEOUT,
                ];
 
                $options['nextcloud']['allow_local_address'] = $this->isLocalAddressAllowed($options);
index ad4c018ab7be1c420d812fb1c351a29129db5578..e4f46d44e4dfa76b1bfa876db39f49a547c7cfb5 100644 (file)
@@ -14,6 +14,14 @@ namespace OCP\Http\Client;
  * @since 8.1.0
  */
 interface IClient {
+
+       /**
+        * Default request timeout for requests
+        *
+        * @since 31.0.0
+        */
+       public const DEFAULT_REQUEST_TIMEOUT = 30;
+
        /**
         * Sends a GET request
         * @param string $uri