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

Unified Diff: sdk/lib/io/http_body_impl.dart

Issue 14113006: Fix HttpBodyHandler to handle missing mimeType. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix comment. Created 7 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 | « sdk/lib/io/http.dart ('k') | sdk/lib/io/http_headers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_body_impl.dart
diff --git a/sdk/lib/io/http_body_impl.dart b/sdk/lib/io/http_body_impl.dart
index 4bd9f8171cad26ee7bee0a7cb9654c699e82f9a2..214daa3240767f17ef874206c1f572ec765507ca 100644
--- a/sdk/lib/io/http_body_impl.dart
+++ b/sdk/lib/io/http_body_impl.dart
@@ -47,22 +47,25 @@ class _HttpBodyHandler implements HttpBodyHandler {
.then((list) {
dynamic content = list.readBytes();
String type = "binary";
- String mimeType = headers.contentType.toString();
+ ContentType contentType = headers.contentType;
+ if (contentType == null) {
+ return new _HttpBody(null, type, content);
+ }
String asText(Encoding defaultEncoding) {
var encoding;
- var charset = headers.contentType.charset;
+ var charset = contentType.charset;
if (charset != null) encoding = Encoding.fromName(charset);
if (encoding == null) encoding = defaultEncoding;
return _decodeString(content, encoding);
}
- switch (headers.contentType.primaryType) {
+ switch (contentType.primaryType) {
case "text":
type = "text";
content = asText(Encoding.ASCII);
break;
case "application":
- switch (headers.contentType.subType) {
+ switch (contentType.subType) {
case "json":
content = JSON.parse(asText(Encoding.UTF_8));
type = "json";
@@ -76,7 +79,7 @@ class _HttpBodyHandler implements HttpBodyHandler {
default:
break;
}
- return new _HttpBody(mimeType, type, content);
+ return new _HttpBody(contentType.mimeType, type, content);
});
}
}
« no previous file with comments | « sdk/lib/io/http.dart ('k') | sdk/lib/io/http_headers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698