From a462a88ee76f80bfacc5cad240530ff8e937c017 Mon Sep 17 00:00:00 2001 From: Rafael da Silva Ferreira Date: Sat, 19 Feb 2022 22:41:10 -0300 Subject: [PATCH] Add customClient to internal constructor of SecureHttpClient --- example/pubspec.lock | 2 +- lib/src/http_client/secure_http_client.dart | 14 ++++++++++---- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 28e512c..c8cfca9 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -80,7 +80,7 @@ packages: path: ".." relative: true source: path - version: "2.0.1" + version: "2.0.4" http_parser: dependency: transitive description: diff --git a/lib/src/http_client/secure_http_client.dart b/lib/src/http_client/secure_http_client.dart index ae2000c..b17915e 100644 --- a/lib/src/http_client/secure_http_client.dart +++ b/lib/src/http_client/secure_http_client.dart @@ -9,13 +9,19 @@ import 'package:http_certificate_pinning/http_certificate_pinning.dart'; class SecureHttpClient extends http.BaseClient { List allowedSHAFingerprints; - final IOClient _client = IOClient(); + http.BaseClient _client = IOClient(); - SecureHttpClient._internal({required this.allowedSHAFingerprints}); + SecureHttpClient._internal({required this.allowedSHAFingerprints, http.BaseClient? customClient}) { + if (customClient != null) { + _client = customClient; + } + } - factory SecureHttpClient.build(List allowedSHAFingerprints) { + factory SecureHttpClient.build(List allowedSHAFingerprints, {http.BaseClient? customClient}) { return SecureHttpClient._internal( - allowedSHAFingerprints: allowedSHAFingerprints); + allowedSHAFingerprints: allowedSHAFingerprints, + customClient: customClient + ); } Future head(url, {Map? headers}) => diff --git a/pubspec.yaml b/pubspec.yaml index 895c280..7a08e47 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: http_certificate_pinning description: Https Certificate pinning for Flutter -version: 2.0.3 +version: 2.0.4 author: Diefferson Santos homepage: https://github.com/diefferson/http_certificate_pinning