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

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

Issue 1390353005: Web Socket compression - take two (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix observatory issues Created 5 years, 1 month 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/websocket.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 47001282fce35a26c2eba1d4b7bfc8f3e1bc419a..676e4a88e10ebed8c0ceb33b340ca026c0a62ea5 100644
--- a/sdk/lib/io/http_headers.dart
+++ b/sdk/lib/io/http_headers.dart
@@ -630,10 +630,11 @@ class _HeaderValue implements HeaderValue {
static _HeaderValue parse(String value,
{parameterSeparator: ";",
+ valueSeparator: null,
preserveBackslash: false}) {
// Parse the string.
var result = new _HeaderValue();
- result._parse(value, parameterSeparator, preserveBackslash);
+ result._parse(value, parameterSeparator, valueSeparator, preserveBackslash);
return result;
}
@@ -664,7 +665,10 @@ class _HeaderValue implements HeaderValue {
return sb.toString();
}
- void _parse(String s, String parameterSeparator, bool preserveBackslash) {
+ void _parse(String s,
+ String parameterSeparator,
+ String valueSeparator,
+ bool preserveBackslash) {
int index = 0;
bool done() => index == s.length;
@@ -681,6 +685,7 @@ class _HeaderValue implements HeaderValue {
while (!done()) {
if (s[index] == " " ||
s[index] == "\t" ||
+ s[index] == valueSeparator ||
s[index] == parameterSeparator) break;
index++;
}
@@ -705,14 +710,17 @@ class _HeaderValue implements HeaderValue {
String parseParameterName() {
int start = index;
while (!done()) {
- if (s[index] == " " || s[index] == "\t" || s[index] == "=") break;
+ if (s[index] == " " ||
+ s[index] == "\t" ||
+ s[index] == "=" ||
+ s[index] == valueSeparator) break;
index++;
}
return s.substring(start, index).toLowerCase();
}
String parseParameterValue() {
- if (s[index] == "\"") {
+ if (!done() && s[index] == "\"") {
// Parse quoted value.
StringBuffer sb = new StringBuffer();
index++;
@@ -735,7 +743,8 @@ class _HeaderValue implements HeaderValue {
return sb.toString();
} else {
// Parse non-quoted value.
- return parseValue();
+ var val = parseValue();
+ return val == "" ? null : val;
}
}
@@ -744,8 +753,16 @@ class _HeaderValue implements HeaderValue {
if (done()) return;
String name = parseParameterName();
skipWS();
- expect("=");
+ if (done()) {
+ parameters[name] = null;
+ return;
+ }
+ maybeExpect("=");
skipWS();
+ if(done()) {
+ parameters[name] = null;
+ return;
+ }
String value = parseParameterValue();
if (name == 'charset' && this is _ContentType) {
// Charset parameter of ContentTypes are always lower-case.
@@ -754,6 +771,8 @@ class _HeaderValue implements HeaderValue {
parameters[name] = value;
skipWS();
if (done()) return;
+ // TODO: Implement support for multi-valued parameters.
+ if(s[index] == valueSeparator) return;
expect(parameterSeparator);
}
}
@@ -800,7 +819,7 @@ class _ContentType extends _HeaderValue implements ContentType {
static _ContentType parse(String value) {
var result = new _ContentType._();
- result._parse(value, ";", false);
+ result._parse(value, ";", null, false);
int index = result._value.indexOf("/");
if (index == -1 || index == (result._value.length - 1)) {
result._primaryType = result._value.trim().toLowerCase();
« no previous file with comments | « sdk/lib/io/http.dart ('k') | sdk/lib/io/websocket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698