Skip to content

Commit

Permalink
Increase request timeout to 300s and make configurable.
Browse files Browse the repository at this point in the history
(cherry picked from commit 2485073)
  • Loading branch information
fancycode committed Apr 9, 2024
1 parent 2af3321 commit f149a5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function shareFile(File $file, array $recipients, ?array $metadata, array
'headers' => $headers,
'multipart' => $multipart,
'verify' => !$this->config->insecureSkipVerify(),
'timeout' => $this->config->getRequestTimeout(),
]);
$body = $response->getBody();
return json_decode($body, true);
Expand All @@ -120,6 +121,7 @@ public function signFile(string $id, array $multipart, array $account, string $s
'headers' => $headers,
'multipart' => $multipart,
'verify' => !$this->config->insecureSkipVerify(),
'timeout' => $this->config->getRequestTimeout(),
]);
$body = $response->getBody();
return json_decode($body, true);
Expand All @@ -136,6 +138,7 @@ public function deleteFile(string $id, array $account, string $server): array {
$response = $client->delete($server . 'api/v1/files/' . rawurlencode($account['id']) . '/' . rawurlencode($id), [
'headers' => $headers,
'verify' => !$this->config->insecureSkipVerify(),
'timeout' => $this->config->getRequestTimeout(),
]);
$body = $response->getBody();
return json_decode($body, true);
Expand Down Expand Up @@ -172,6 +175,7 @@ public function downloadSignedFile(string $id, array $account, string $server) {
$response = $client->get($url, [
'headers' => $headers,
'verify' => !$this->config->insecureSkipVerify(),
'timeout' => $this->config->getRequestTimeout(),
]);
$body = $response->getBody();
return $body;
Expand All @@ -190,6 +194,7 @@ public function getSignatureDetails(string $id, array $account, string $server,
$response = $client->get($url, [
'headers' => $headers,
'verify' => !$this->config->insecureSkipVerify(),
'timeout' => $this->config->getRequestTimeout(),
]);
$body = $response->getBody();
return $body;
Expand Down Expand Up @@ -230,6 +235,7 @@ public function verifySignatures(File $file, array $account, string $server) {
'headers' => $headers,
'multipart' => $multipart,
'verify' => !$this->config->insecureSkipVerify(),
'timeout' => $this->config->getRequestTimeout(),
]);
$body = $response->getBody();
return json_decode($body, true);
Expand Down
10 changes: 10 additions & 0 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Config {

public const DEFAULT_API_SERVER = "https://api.certificate24.com/";
public const DEFAULT_WEB_SERVER = "https://www.certificate24.com/";
public const DEFAULT_REQUEST_TIMEOUT = '300';
public const DEFAULT_SAVE_MODE = 'new';

private IConfig $config;
Expand Down Expand Up @@ -71,6 +72,15 @@ public function getWebServer(): string {
return $server;
}

public function getRequestTimeout(): int {
$timeout = $this->config->getAppValue(self::APP_ID, 'timeout', self::DEFAULT_REQUEST_TIMEOUT);
if (empty($timeout)) {
$timeout = self::DEFAULT_REQUEST_TIMEOUT;
}

return (int) $timeout;
}

public function getAccount(): array {
$account = $this->config->getAppValue(self::APP_ID, 'account', '');
if (!$account) {
Expand Down

0 comments on commit f149a5f

Please sign in to comment.