mirror of
https://github.com/immich-app/immich.git
synced 2025-02-06 18:45:04 +02:00
chore(mobile): use sdk to for ping endpoint (#13218)
This commit is contained in:
parent
4bb42c4a25
commit
6f86c2f372
@ -97,27 +97,13 @@ class ApiService implements Authentication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _isEndpointAvailable(String serverUrl) async {
|
Future<bool> _isEndpointAvailable(String serverUrl) async {
|
||||||
final Client client = Client();
|
|
||||||
|
|
||||||
if (!serverUrl.endsWith('/api')) {
|
if (!serverUrl.endsWith('/api')) {
|
||||||
serverUrl += '/api';
|
serverUrl += '/api';
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await client
|
await setEndpoint(serverUrl);
|
||||||
.get(
|
await serverInfoApi.pingServer().timeout(Duration(seconds: 5));
|
||||||
Uri.parse("$serverUrl/server-info/ping"),
|
|
||||||
headers: getRequestHeaders(),
|
|
||||||
)
|
|
||||||
.timeout(const Duration(seconds: 5));
|
|
||||||
|
|
||||||
_log.info("Pinging server with response code ${response.statusCode}");
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
_log.severe(
|
|
||||||
"Server Gateway Error: ${response.body} - Cannot communicate to the server",
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} on TimeoutException catch (_) {
|
} on TimeoutException catch (_) {
|
||||||
return false;
|
return false;
|
||||||
} on SocketException catch (_) {
|
} on SocketException catch (_) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user