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

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: 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 | « no previous file | tests/standalone/io/http_body_test.dart » ('j') | tests/standalone/io/http_body_test.dart » ('J')
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..f8431bd37101591fe47f578b62e097392d84fdc2 100644
--- a/sdk/lib/io/http_body_impl.dart
+++ b/sdk/lib/io/http_body_impl.dart
@@ -47,22 +47,26 @@ 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 mimeType = "${contentType.primaryType}/${contentType.subType}";
Søren Gjesse 2013/04/15 11:11:28 Maybe add gettet type or value to class ContentTyp
Anders Johnsen 2013/04/15 11:19:26 Done.
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";
« no previous file with comments | « no previous file | tests/standalone/io/http_body_test.dart » ('j') | tests/standalone/io/http_body_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698