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

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

Issue 14914002: Change fromString constructor to parse static method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed additional tests Created 7 years, 7 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_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_headers.dart
diff --git a/sdk/lib/io/http_headers.dart b/sdk/lib/io/http_headers.dart
index 919761ab6dbedb2e4b9a0f28db22ecc5b039d597..f6f756bce094cf9b7d5fe6f6ed9d391f17e8f676 100644
--- a/sdk/lib/io/http_headers.dart
+++ b/sdk/lib/io/http_headers.dart
@@ -196,7 +196,7 @@ class _HttpHeaders implements HttpHeaders {
ContentType get contentType {
var values = _headers["content-type"];
if (values != null) {
- return new ContentType.fromString(values[0]);
+ return ContentType.parse(values[0]);
} else {
return null;
}
@@ -477,9 +477,11 @@ class _HeaderValue implements HeaderValue {
_HeaderValue([String this._value = "", this._parameters]);
- _HeaderValue.fromString(String value, {parameterSeparator: ";"}) {
+ static _HeaderValue parse(String value, {parameterSeparator: ";"}) {
// Parse the string.
- _parse(value, parameterSeparator);
+ var result = new _HeaderValue();
+ result._parse(value, parameterSeparator);
+ return result;
}
String get value => _value;
@@ -621,15 +623,20 @@ class _ContentType extends _HeaderValue implements ContentType {
}
}
- _ContentType.fromString(String value) : super.fromString(value) {
- int index = _value.indexOf("/");
- if (index == -1 || index == (_value.length - 1)) {
- _primaryType = _value.trim().toLowerCase();
- _subType = "";
+ _ContentType._();
+
+ static _ContentType parse(String value) {
+ var result = new _ContentType._();
+ result._parse(value, ";");
+ int index = result._value.indexOf("/");
+ if (index == -1 || index == (result._value.length - 1)) {
+ result._primaryType = result._value.trim().toLowerCase();
+ result._subType = "";
} else {
- _primaryType = _value.substring(0, index).trim().toLowerCase();
- _subType = _value.substring(index + 1).trim().toLowerCase();
+ result._primaryType = result._value.substring(0, index).trim().toLowerCase();
+ result._subType = result._value.substring(index + 1).trim().toLowerCase();
}
+ return result;
}
String get mimeType => '$primaryType/$subType';
« no previous file with comments | « sdk/lib/io/http.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698