fix: Use retry http client
This commit is contained in:
parent
c9e4c2aa11
commit
2797974d45
3 changed files with 24 additions and 4 deletions
|
|
@ -3,9 +3,15 @@ import 'dart:io';
|
|||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:http/retry.dart' as retry;
|
||||
|
||||
import 'package:fluffychat/config/isrg_x1.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
|
||||
/// Custom Client to add an additional certificate. This is for the isrg X1
|
||||
/// certificate which is needed for LetsEncrypt certificates. It is shipped
|
||||
/// on Android since OS version 7.1. As long as we support older versions we
|
||||
/// still have to ship this certificate by ourself.
|
||||
class CustomHttpClient {
|
||||
static HttpClient customHttpClient(String? cert) {
|
||||
final context = SecurityContext.defaultContext;
|
||||
|
|
@ -26,5 +32,9 @@ class CustomHttpClient {
|
|||
return HttpClient(context: context);
|
||||
}
|
||||
|
||||
static http.Client createHTTPClient() => IOClient(customHttpClient(ISRG_X1));
|
||||
static http.Client createHTTPClient() => retry.RetryClient(
|
||||
PlatformInfos.isAndroid
|
||||
? IOClient(customHttpClient(ISRG_X1))
|
||||
: http.Client(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue