Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Unified Diff: lib/src/media_type.dart

Issue 1419493002: Make MediaType case-insensitive, following the spec. (Closed) Base URL: git@github.com:dart-lang/http_parser@master
Patch Set: Add tests Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/media_type.dart
diff --git a/lib/src/media_type.dart b/lib/src/media_type.dart
index 5bae0ec2ad6cd404afb0c1aeb1575ce44dc0181d..e15bccf2f5ded779a34e9182d34aa54d3fd3e4f2 100644
--- a/lib/src/media_type.dart
+++ b/lib/src/media_type.dart
@@ -7,6 +7,7 @@ library http_parser.media_type;
import 'package:collection/collection.dart';
import 'package:string_scanner/string_scanner.dart';
+import 'case_insensitive_map.dart';
import 'scan.dart';
import 'utils.dart';
@@ -21,14 +22,18 @@ final _escapedChar = new RegExp(r'["\x00-\x1F\x7F]');
/// calling [change].
class MediaType {
/// The primary identifier of the MIME type.
+ ///
+ /// This is always lowercase.
final String type;
/// The secondary identifier of the MIME type.
+ ///
+ /// This is always lowercase.
final String subtype;
/// The parameters to the media type.
///
- /// This map is immutable.
+ /// This map is immutable and the keys are case-insensitive.
final Map<String, String> parameters;
/// The media type's MIME type.
@@ -73,9 +78,11 @@ class MediaType {
});
}
- MediaType(this.type, this.subtype, [Map<String, String> parameters])
- : this.parameters = new UnmodifiableMapView(
- parameters == null ? {} : new Map.from(parameters));
+ MediaType(String type, String subtype, [Map<String, String> parameters])
+ : type = type.toLowerCase(),
+ subtype = subtype.toLowerCase(),
+ parameters = new UnmodifiableMapView(
+ parameters == null ? {} : new CaseInsensitiveMap.from(parameters));
/// Returns a copy of this [MediaType] with some fields altered.
///
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698