A cross platform Audiobookshelf client for Android and iOS
Dart
Stop using the iPhone's own network stack for server requests
Barnabasd08cf6a169da
diff --git a/lib/main.dart b/lib/main.dartindex 60093b1d..65fca1d0 100644--- a/lib/main.dart+++ b/lib/main.dart@@ -11,9 +11,6 @@ import 'package:flutter/services.dart';import 'package:provider/provider.dart';import 'package:permission_handler/permission_handler.dart';import 'package:flutter_native_splash/flutter_native_splash.dart';-import 'package:http/http.dart' show Client, runWithClient;-import 'package:http/io_client.dart' show IOClient;-import 'package:cupertino_http/cupertino_http.dart' show CupertinoClient, URLSessionConfiguration;import 'l10n/app_localizations.dart';import 'package:device_info_plus/device_info_plus.dart';@@ -116,28 +113,6 @@ void applyTrustAllCerts(bool enabled) {trustAllCerts = enabled;}-/// Builds the HTTP client used by every `package:http` call in the app-/// (installed via [runWithClient] in [main]).-///-/// On iOS we route through NSURLSession (CupertinoClient) so the app talks to-/// the server the same way Safari does: it honours the system proxy and uses-/// the OS TLS stack. That gets past proxies/firewalls that reset Dart's own-/// connections even when the browser gets through (GH #268).-///-/// Self-signed / custom-CA users (trustAllCerts on) stay on the dart:io client,-/// because the trust-all override lives in [_CertOverrides.badCertificateCallback]-/// and NSURLSession wouldn't honour it. The flag is read per request, so toggling-/// it in settings takes effect on the next call. Everywhere else keeps the-/// existing dart:io client.-Client _createHttpClient() {- if (Platform.isIOS && !trustAllCerts) {- return CupertinoClient.fromSessionConfiguration(- URLSessionConfiguration.ephemeralSessionConfiguration(),- );- }- return IOClient();-}-/// Global key so non-widget code (e.g. providers) can show snackbars.final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =GlobalKey<ScaffoldMessengerState>();@@ -183,15 +158,7 @@ Future<void> applyOrientationLock() async {]);}-void main() {- // Run the whole app inside the runWithClient zone so that package:http calls- // pick up _createHttpClient. The binding must be initialised inside the zone- // (in _runApp) or platform/gesture callbacks would escape it and fall back to- // the default client.- runWithClient(_runApp, _createHttpClient);-}--Future<void> _runApp() async {+void main() async {HttpOverrides.global = _CertOverrides();final widgetsBinding = WidgetsFlutterBinding.ensureInitialized();diff --git a/pubspec.lock b/pubspec.lockindex 010798ad..db536407 100644--- a/pubspec.lock+++ b/pubspec.lock@@ -144,14 +144,6 @@ packages:url: "https://pub.dev"source: hostedversion: "1.1.2"- code_assets:- dependency: transitive- description:- name: code_assets- sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8- url: "https://pub.dev"- source: hosted- version: "1.2.1"collection:dependency: transitivedescription:@@ -200,14 +192,6 @@ packages:url: "https://pub.dev"source: hostedversion: "1.0.2"- cupertino_http:- dependency: "direct main"- description:- name: cupertino_http- sha256: "3c8c69cc1b94b9c7570d9454bf1e11fa7010b248547a0760843adc71f0c08fbe"- url: "https://pub.dev"- source: hosted- version: "3.0.2"dbus:dependency: transitivedescription:@@ -419,14 +403,6 @@ packages:url: "https://pub.dev"source: hostedversion: "4.7.3"- glob:- dependency: transitive- description:- name: glob- sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de- url: "https://pub.dev"- source: hosted- version: "2.1.3"home_widget:dependency: "direct main"description:@@ -435,14 +411,6 @@ packages:url: "https://pub.dev"source: hostedversion: "0.7.0+1"- hooks:- dependency: transitive- description:- name: hooks- sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba"- url: "https://pub.dev"- source: hosted- version: "2.0.2"html:dependency: transitivedescription:@@ -467,14 +435,6 @@ packages:url: "https://pub.dev"source: hostedversion: "4.1.2"- http_profile:- dependency: transitive- description:- name: http_profile- sha256: "7e679e355b09aaee2ab5010915c932cce3f2d1c11c3b2dc177891687014ffa78"- url: "https://pub.dev"- source: hosted- version: "0.1.0"image:dependency: transitivedescription:@@ -642,14 +602,6 @@ packages:url: "https://pub.dev"source: hostedversion: "1.0.5"- native_toolchain_c:- dependency: transitive- description:- name: native_toolchain_c- sha256: f59351d28f49520cd3a74eb1f41c5f19ae15e53c65a3231d14af672e46510a96- url: "https://pub.dev"- source: hosted- version: "0.19.1"nested:dependency: transitivedescription:@@ -666,14 +618,6 @@ packages:url: "https://pub.dev"source: hostedversion: "0.5.0"- objective_c:- dependency: transitive- description:- name: objective_c- sha256: "6cb691c686fa2838c6deb34980d426145c2a5d537491cb83d463c33cdbc726ed"- url: "https://pub.dev"- source: hosted- version: "9.4.1"octo_image:dependency: transitivedescription:@@ -858,14 +802,6 @@ packages:url: "https://pub.dev"source: hostedversion: "6.1.5+1"- pub_semver:- dependency: transitive- description:- name: pub_semver- sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585"- url: "https://pub.dev"- source: hosted- version: "2.2.0"quick_actions:dependency: "direct main"description:@@ -898,14 +834,6 @@ packages:url: "https://pub.dev"source: hostedversion: "1.1.0"- record_use:- dependency: transitive- description:- name: record_use- sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed"- url: "https://pub.dev"- source: hosted- version: "0.6.0"rename_app:dependency: "direct dev"description:@@ -1263,14 +1191,6 @@ packages:url: "https://pub.dev"source: hostedversion: "1.1.1"- web_socket:- dependency: transitive- description:- name: web_socket- sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c"- url: "https://pub.dev"- source: hosted- version: "1.0.1"webview_flutter:dependency: "direct main"description:diff --git a/pubspec.yaml b/pubspec.yamlindex a3a0226c..26bc009d 100644--- a/pubspec.yaml+++ b/pubspec.yaml@@ -92,7 +92,6 @@ dependencies:webview_flutter: ^4.13.1flutter_markdown_plus: ^1.0.7palette_generator: ^0.3.3+7- cupertino_http: ^3.0.2dev_dependencies:flutter_test: