Skip to content

Commit 79e0584

Browse files
author
Julien Veyssier
committed
make connectivity check less strict, test https OR ELSE http
Signed-off-by: Julien Veyssier <[email protected]>
1 parent 213e75b commit 79e0584

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,25 +198,25 @@ private function hasInternetConnectivityProblems(): bool {
198198
}
199199

200200
/**
201-
* Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
201+
* Checks if the Nextcloud server can connect to a specific URL using either HTTPS or HTTP
202202
* @return bool
203203
*/
204204
private function isSiteReachable($sitename) {
205-
$httpSiteName = 'http://' . $sitename . '/';
206-
$httpsSiteName = 'https://' . $sitename . '/';
205+
$client = $this->clientService->newClient();
207206

208-
try {
209-
$client = $this->clientService->newClient();
210-
$client->get($httpSiteName);
211-
$client->get($httpsSiteName);
212-
} catch (\Exception $e) {
213-
$this->logger->error('Cannot connect to: ' . $sitename, [
214-
'app' => 'internet_connection_check',
215-
'exception' => $e,
216-
]);
217-
return false;
207+
foreach (['https', 'http'] as $proto) {
208+
$siteUrl = $proto . '://' . $sitename . '/';
209+
try {
210+
$client->get($siteUrl);
211+
return true;
212+
} catch (\Exception $e) {
213+
$this->logger->error('Cannot connect to: ' . $sitename, [
214+
'app' => 'internet_connection_check',
215+
'exception' => $e,
216+
]);
217+
}
218218
}
219-
return true;
219+
return false;
220220
}
221221

222222
/**

0 commit comments

Comments
 (0)