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

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

Issue 216603010: Rip out dart:io from pkg/http wherever possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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/http/lib/src/request.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/response.dart
diff --git a/pkg/http/lib/src/response.dart b/pkg/http/lib/src/response.dart
index afbb7141f67a7b7a0fe1f155c48f05db1bd3d8a6..a107d0c4d88ad9bb5e89658538d725fe26d790ca 100644
--- a/pkg/http/lib/src/response.dart
+++ b/pkg/http/lib/src/response.dart
@@ -6,9 +6,10 @@ library response;
import 'dart:async';
import 'dart:convert';
-import 'dart:io';
import 'dart:typed_data';
+import 'package:http_parser/http_parser.dart';
+
import 'base_request.dart';
import 'base_response.dart';
import 'streamed_response.dart';
@@ -84,12 +85,13 @@ class Response extends BaseResponse {
/// defaults to [LATIN1] if the headers don't specify a charset or
/// if that charset is unknown.
Encoding _encodingForHeaders(Map<String, String> headers) =>
- encodingForCharset(_contentTypeForHeaders(headers).charset);
+ encodingForCharset(_contentTypeForHeaders(headers).parameters['charset']);
-/// Returns the [ContentType] object for the given headers. Defaults to
-/// `application/octet-stream`.
-ContentType _contentTypeForHeaders(Map<String, String> headers) {
- var contentType = headers[HttpHeaders.CONTENT_TYPE];
- if (contentType != null) return ContentType.parse(contentType);
- return new ContentType("application", "octet-stream");
+/// Returns the [MediaType] object for the given headers's content-type.
+///
+/// Defaults to `application/octet-stream`.
+MediaType _contentTypeForHeaders(Map<String, String> headers) {
+ var contentType = headers['content-type'];
+ if (contentType != null) return new MediaType.parse(contentType);
+ return new MediaType("application", "octet-stream");
}
« no previous file with comments | « pkg/http/lib/src/request.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698