Chromium Code Reviews| Index: pkg/shelf/lib/src/message.dart |
| diff --git a/pkg/shelf/lib/src/message.dart b/pkg/shelf/lib/src/message.dart |
| index 737c72224f88ee21172239a971e776371ddf7dba..5ff713519749b392578ecf86ca98306aa6c62676 100644 |
| --- a/pkg/shelf/lib/src/message.dart |
| +++ b/pkg/shelf/lib/src/message.dart |
| @@ -5,14 +5,16 @@ |
| library shelf.message; |
| import 'dart:async'; |
| +import 'dart:collection'; |
| import 'dart:convert'; |
| -import 'package:collection/wrappers.dart'; |
| +// TODO(kevmoo): use UnmodifiableMapView from SDK once 1.4 ships |
| +import 'package:collection/wrappers.dart' as pc show UnmodifiableMapView; |
|
nweiz
2014/04/08 20:23:09
There's never a reason to use "show" and "as" in t
kevmoo
2014/04/08 21:41:13
Done.
|
| import 'package:http_parser/http_parser.dart'; |
| import 'package:stack_trace/stack_trace.dart'; |
| /// Represents logic shared between [Request] and [Response]. |
| -abstract class Message { |
| +class Message { |
| /// The HTTP headers. |
| /// |
| /// The value is immutable. |
| @@ -23,8 +25,8 @@ abstract class Message { |
| /// This can be read via [read] or [readAsString]. |
| final Stream<List<int>> _body; |
| - Message(UnmodifiableMapView<String, String> headers, this._body) |
| - : this.headers = headers; |
| + Message(Map<String, String> headers, this._body) |
| + : this.headers = _getIgnoreCaseMapView(headers); |
| /// The contents of the content-length field in [headers]. |
| /// |
| @@ -92,3 +94,14 @@ abstract class Message { |
| return Chain.track(encoding.decodeStream(read())); |
| } |
| } |
| + |
| +pc.UnmodifiableMapView _getIgnoreCaseMapView(Map headers) { |
|
nweiz
2014/04/08 20:23:09
Document this.
kevmoo
2014/04/08 21:41:13
Done.
|
| + var map = new LinkedHashMap( |
| + equals: (key1, key2) => key1.toLowerCase() == key2.toLowerCase(), |
| + hashCode: (key) => key.toLowerCase().hashCode); |
|
nweiz
2014/04/08 20:23:09
Add a TODO to use a canonicalized map once somethi
kevmoo
2014/04/08 21:41:13
Done.
|
| + |
| + map.addAll(headers); |
| + |
| + // TODO(kevmoo): use UnmodifiableMapView from SDK once 1.4 ships |
|
nweiz
2014/04/08 20:23:09
You don't need this TODO twice in the same file.
kevmoo
2014/04/08 21:41:13
Done.
|
| + return new pc.UnmodifiableMapView(map); |
| +} |