Skip to content

Commit

Permalink
Merge pull request #24 from RafaelPlantard/feature/interception
Browse files Browse the repository at this point in the history
Add customClient to internal constructor of SecureHttpClient
  • Loading branch information
diefferson authored Feb 21, 2022
2 parents 516d5cd + a462a88 commit ea1b84c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.1"
version: "2.0.4"
http_parser:
dependency: transitive
description:
Expand Down
14 changes: 10 additions & 4 deletions lib/src/http_client/secure_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import 'package:http_certificate_pinning/http_certificate_pinning.dart';
class SecureHttpClient extends http.BaseClient {
List<String> 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<String> allowedSHAFingerprints) {
factory SecureHttpClient.build(List<String> allowedSHAFingerprints, {http.BaseClient? customClient}) {
return SecureHttpClient._internal(
allowedSHAFingerprints: allowedSHAFingerprints);
allowedSHAFingerprints: allowedSHAFingerprints,
customClient: customClient
);
}

Future<Response> head(url, {Map<String, String>? headers}) =>
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
homepage: https://github.com/diefferson/http_certificate_pinning

Expand Down

0 comments on commit ea1b84c

Please sign in to comment.