Skip to content

Commit 205af79

Browse files
authored
Merge pull request #48639 from nextcloud/add-default-request-timeout-const
feat(http client): expose default request timeout constant to be used instead of magic number 30
2 parents d013a13 + dcd27fd commit 205af79

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lib/private/Files/Storage/DAV.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use OCP\Files\IMimeTypeDetector;
2121
use OCP\Files\StorageInvalidException;
2222
use OCP\Files\StorageNotAvailableException;
23+
use OCP\Http\Client\IClient;
2324
use OCP\Http\Client\IClientService;
2425
use OCP\ICertificateManager;
2526
use OCP\IConfig;
@@ -124,7 +125,7 @@ public function __construct($params) {
124125
$this->logger = Server::get(LoggerInterface::class);
125126
$this->eventLogger = Server::get(IEventLogger::class);
126127
// This timeout value will be used for the download and upload of files
127-
$this->timeout = Server::get(IConfig::class)->getSystemValueInt('davstorage.request_timeout', 30);
128+
$this->timeout = Server::get(IConfig::class)->getSystemValueInt('davstorage.request_timeout', IClient::DEFAULT_REQUEST_TIMEOUT);
128129
$this->mimeTypeDetector = \OC::$server->getMimeTypeDetector();
129130
}
130131

lib/private/Http/Client/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private function buildRequestOptions(array $options): array {
5353

5454
$defaults = [
5555
RequestOptions::VERIFY => $this->getCertBundle(),
56-
RequestOptions::TIMEOUT => 30,
56+
RequestOptions::TIMEOUT => IClient::DEFAULT_REQUEST_TIMEOUT,
5757
];
5858

5959
$options['nextcloud']['allow_local_address'] = $this->isLocalAddressAllowed($options);

lib/public/Http/Client/IClient.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
* @since 8.1.0
1515
*/
1616
interface IClient {
17+
18+
/**
19+
* Default request timeout for requests
20+
*
21+
* @since 31.0.0
22+
*/
23+
public const DEFAULT_REQUEST_TIMEOUT = 30;
24+
1725
/**
1826
* Sends a GET request
1927
* @param string $uri

0 commit comments

Comments
 (0)