From 06318672be19c3bb22fac717b9afa7e529542d3a Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Wed, 12 Feb 2025 16:23:51 +0100 Subject: [PATCH 1/2] Http-parser: Make CaseInsensitiveMap be extension type. Avoids extending a class unnecessarily, which *may* pave the way for `package:collection` making the class final. --- pkgs/http_parser/CHANGELOG.md | 5 +++++ .../lib/src/case_insensitive_map.dart | 19 ++++++++++--------- pkgs/http_parser/pubspec.yaml | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pkgs/http_parser/CHANGELOG.md b/pkgs/http_parser/CHANGELOG.md index 4312f63cc1..29a656a544 100644 --- a/pkgs/http_parser/CHANGELOG.md +++ b/pkgs/http_parser/CHANGELOG.md @@ -1,3 +1,8 @@ +## 4.1.3 + +* Makes `CaseInsensitiveMap` an extension type. + Allows `package:collection` to make the class `final`. + ## 4.1.2 * Fixed a bug where parsing quoted header values could require a regex to diff --git a/pkgs/http_parser/lib/src/case_insensitive_map.dart b/pkgs/http_parser/lib/src/case_insensitive_map.dart index ed344e6f24..cc29bbde9d 100644 --- a/pkgs/http_parser/lib/src/case_insensitive_map.dart +++ b/pkgs/http_parser/lib/src/case_insensitive_map.dart @@ -7,19 +7,20 @@ import 'package:collection/collection.dart'; /// A map from case-insensitive strings to values. /// /// Much of HTTP is case-insensitive, so this is useful to have pre-defined. -class CaseInsensitiveMap extends CanonicalizedMap { +extension type CaseInsensitiveMap._(Map _) + implements Map { /// Creates an empty case-insensitive map. - CaseInsensitiveMap() : super(_canonicalizer); + CaseInsensitiveMap() + : this._(CanonicalizedMap(_canonicalize)); - /// Creates a case-insensitive map that is initialized with the key/value - /// pairs of [other]. + /// Creates a case-insensitive map initialized with the entries of [other]. CaseInsensitiveMap.from(Map other) - : super.from(other, _canonicalizer); + : this._(CanonicalizedMap.from(other, _canonicalize)); - /// Creates a case-insensitive map that is initialized with the key/value - /// pairs of [entries]. + /// Creates a case-insensitive map initialized with the [entries]. CaseInsensitiveMap.fromEntries(Iterable> entries) - : super.fromEntries(entries, _canonicalizer); + : this._(CanonicalizedMap.fromEntries( + entries, _canonicalize)); - static String _canonicalizer(String key) => key.toLowerCase(); + static String _canonicalize(String key) => key.toLowerCase(); } diff --git a/pkgs/http_parser/pubspec.yaml b/pkgs/http_parser/pubspec.yaml index 5b3d521801..5e4640b0e7 100644 --- a/pkgs/http_parser/pubspec.yaml +++ b/pkgs/http_parser/pubspec.yaml @@ -1,5 +1,5 @@ name: http_parser -version: 4.1.2 +version: 4.1.3 description: >- A platform-independent package for parsing and serializing HTTP formats. repository: https://github.com/dart-lang/http/tree/master/pkgs/http_parser @@ -14,5 +14,5 @@ dependencies: typed_data: ^1.3.0 dev_dependencies: - dart_flutter_team_lints: ^3.0.0 + dart_flutter_team_lints: ^3.3.0 test: ^1.16.6 From 8ae9f4bf1e2e8c5528df25bb7caccc15314f1963 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Wed, 12 Feb 2025 16:43:06 +0100 Subject: [PATCH 2/2] Down upgrade lints yet. Something depends on something. --- pkgs/http_parser/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/http_parser/pubspec.yaml b/pkgs/http_parser/pubspec.yaml index 5e4640b0e7..4b279f7b28 100644 --- a/pkgs/http_parser/pubspec.yaml +++ b/pkgs/http_parser/pubspec.yaml @@ -14,5 +14,5 @@ dependencies: typed_data: ^1.3.0 dev_dependencies: - dart_flutter_team_lints: ^3.3.0 + dart_flutter_team_lints: ^3.1.0 test: ^1.16.6