Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(http client): expose default request timeout constant to be used instead of magic number 30 #48639

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -124,7 +125,7 @@ public function __construct($params) {
$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();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/private/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function buildRequestOptions(array $options): array {

$defaults = [
RequestOptions::VERIFY => $this->getCertBundle(),
RequestOptions::TIMEOUT => 30,
RequestOptions::TIMEOUT => IClient::DEFAULT_REQUEST_TIMEOUT,
];

$options['nextcloud']['allow_local_address'] = $this->isLocalAddressAllowed($options);
Expand Down
8 changes: 8 additions & 0 deletions lib/public/Http/Client/IClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
* @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
Expand Down
Loading