diff --git a/lib/services/github_api.dart b/lib/services/github_api.dart index 3af68e0e36..8e32ae60d0 100644 --- a/lib/services/github_api.dart +++ b/lib/services/github_api.dart @@ -6,10 +6,18 @@ import 'package:dio_http_cache_lts/dio_http_cache_lts.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:injectable/injectable.dart'; import 'package:revanced_manager/models/patch.dart'; +import 'package:dio_http2_adapter/dio_http2_adapter.dart'; @lazySingleton class GithubAPI { - final Dio _dio = Dio(BaseOptions(baseUrl: 'https://api.github.com')); + final Dio _dio = Dio( + BaseOptions(baseUrl: 'https://api.github.com'), + )..httpClientAdapter = Http2Adapter( + ConnectionManager( + idleTimeout: 10000, + onClientCreate: (_, config) => config.onBadCertificate = (_) => true, + ), + ); final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig()); final Options _cacheOptions = buildCacheOptions( const Duration(days: 1), diff --git a/lib/services/revanced_api.dart b/lib/services/revanced_api.dart index 5c2b9433fd..ecfeac6303 100644 --- a/lib/services/revanced_api.dart +++ b/lib/services/revanced_api.dart @@ -6,6 +6,7 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:injectable/injectable.dart'; import 'package:revanced_manager/models/patch.dart'; import 'package:timeago/timeago.dart'; +import 'package:dio_http2_adapter/dio_http2_adapter.dart'; @lazySingleton class RevancedAPI { @@ -17,7 +18,15 @@ class RevancedAPI { ); Future initialize(String apiUrl) async { - _dio = Dio(BaseOptions(baseUrl: apiUrl)); + _dio = Dio(BaseOptions( + baseUrl: apiUrl, + )) + ..httpClientAdapter = Http2Adapter( + ConnectionManager( + idleTimeout: 10000, + onClientCreate: (_, config) => config.onBadCertificate = (_) => true, + ), + ); _dio.interceptors.add(_dioCacheManager.interceptor); } diff --git a/pubspec.yaml b/pubspec.yaml index 5440e7f1a2..f03251fc21 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: ref: revanced-manager device_info_plus: ^4.1.2 dio: ^4.0.6 + dio_http2_adapter: ^2.0.0 dio_http_cache_lts: ^0.4.1 dynamic_color: ^1.5.4 dynamic_themes: ^1.1.0