| Index: pkg/shelf/lib/src/message.dart
|
| diff --git a/pkg/shelf/lib/src/message.dart b/pkg/shelf/lib/src/message.dart
|
| index 1b2e966c4660b3375519c985a459362257e00408..1522e1301aac2ca2af36caec47af853ddbec111f 100644
|
| --- a/pkg/shelf/lib/src/message.dart
|
| +++ b/pkg/shelf/lib/src/message.dart
|
| @@ -5,14 +5,13 @@
|
| library shelf.message;
|
|
|
| import 'dart:async';
|
| -import 'dart:collection';
|
| import 'dart:convert';
|
|
|
| -// TODO(kevmoo): use UnmodifiableMapView from SDK once 1.4 ships
|
| -import 'package:collection/wrappers.dart' as pc;
|
| import 'package:http_parser/http_parser.dart';
|
| import 'package:stack_trace/stack_trace.dart';
|
|
|
| +import 'shelf_unmodifiable_map.dart';
|
| +
|
| /// Represents logic shared between [Request] and [Response].
|
| abstract class Message {
|
| /// The HTTP headers.
|
| @@ -43,9 +42,10 @@ abstract class Message {
|
| /// If [headers] is `null`, it is treated as empty.
|
| Message(this._body, {Map<String, String> headers,
|
| Map<String, Object> context})
|
| - : this.headers = _getIgnoreCaseMapView(headers),
|
| - this.context = new pc.UnmodifiableMapView(
|
| - context == null ? const {} : new Map.from(context));
|
| + : this.headers = new ShelfUnmodifiableMap<String>(headers,
|
| + ignoreKeyCase: true),
|
| + this.context = new ShelfUnmodifiableMap<Object>(context,
|
| + ignoreKeyCase: false);
|
|
|
| /// The contents of the content-length field in [headers].
|
| ///
|
| @@ -112,18 +112,8 @@ abstract class Message {
|
| if (encoding == null) encoding = UTF8;
|
| return Chain.track(encoding.decodeStream(read()));
|
| }
|
| -}
|
| -
|
| -/// Creates on an unmodifiable map of [headers] with case-insensitive access.
|
| -Map<String, String> _getIgnoreCaseMapView(Map<String, String> headers) {
|
| - if (headers == null) return const {};
|
| - // TODO(kevmoo) generalize this model with a 'canonical map' to align with
|
| - // similiar implementation in http pkg [BaseRequest].
|
| - var map = new LinkedHashMap<String, String>(
|
| - equals: (key1, key2) => key1.toLowerCase() == key2.toLowerCase(),
|
| - hashCode: (key) => key.toLowerCase().hashCode);
|
| -
|
| - map.addAll(headers);
|
|
|
| - return new pc.UnmodifiableMapView<String, String>(map);
|
| + /// Creates a new [Message] by copying existing values and applying specified
|
| + /// changes.
|
| + Message change({Map<String, String> headers, Map<String, Object> context});
|
| }
|
|
|