File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
apps/settings/lib/Controller Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff 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 /**
You can’t perform that action at this time.
0 commit comments