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

Unified Diff: pkg/shelf/lib/src/response.dart

Issue 227563010: pkg/shelf: case-insensitive headers, cleaner Request ctor, a lot more tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixing dependent code, changelog Created 6 years, 8 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 | « pkg/shelf/lib/src/request.dart ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/lib/src/response.dart
diff --git a/pkg/shelf/lib/src/response.dart b/pkg/shelf/lib/src/response.dart
index 07eba1b4db4e360b59fbf1c04613a1c4c3fa34de..bbc268bed4f7f8a8e9e7e35f8c8559eb3a97bf65 100644
--- a/pkg/shelf/lib/src/response.dart
+++ b/pkg/shelf/lib/src/response.dart
@@ -7,7 +7,6 @@ library shelf.response;
import 'dart:async';
import 'dart:convert';
-import 'package:collection/wrappers.dart';
import 'package:http_parser/http_parser.dart';
import 'message.dart';
@@ -196,8 +195,8 @@ class Response extends Message {
/// Content-Type header, it will be set to "application/octet-stream".
Response(this.statusCode, {body, Map<String, String> headers,
Encoding encoding})
- : super(_adjustHeaders(headers, encoding),
- _bodyToStream(body, encoding)) {
+ : super(_bodyToStream(body, encoding),
+ headers: _adjustHeaders(headers, encoding)) {
if (statusCode < 100) {
throw new ArgumentError("Invalid status code: $statusCode.");
}
@@ -221,19 +220,18 @@ Stream<List<int>> _bodyToStream(body, Encoding encoding) {
/// Adds information about [encoding] to [headers].
///
/// Returns a new map without modifying [headers].
-UnmodifiableMapView<String, String> _adjustHeaders(
+Map<String, String> _adjustHeaders(
Map<String, String> headers, Encoding encoding) {
if (headers == null) headers = const {};
- if (encoding == null) return new UnmodifiableMapView(headers);
+ if (encoding == null) return headers;
if (headers['content-type'] == null) {
- return new UnmodifiableMapView(_addHeader(headers, 'content-type',
- 'application/octet-stream; charset=${encoding.name}'));
+ return _addHeader(headers, 'content-type',
+ 'application/octet-stream; charset=${encoding.name}');
}
var contentType = new MediaType.parse(headers['content-type'])
.change(parameters: {'charset': encoding.name});
- return new UnmodifiableMapView(
- _addHeader(headers, 'content-type', contentType.toString()));
+ return _addHeader(headers, 'content-type', contentType.toString());
}
/// Adds a header with [name] and [value] to [headers], which may be null.
« no previous file with comments | « pkg/shelf/lib/src/request.dart ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698