| Index: sdk/lib/io/http_headers.dart
|
| diff --git a/sdk/lib/io/http_headers.dart b/sdk/lib/io/http_headers.dart
|
| index de6379b8a4561d602be5acae3778996a362d58f6..a8aae51f2e35e76ee8c4d861fba0b6b464f65c5b 100644
|
| --- a/sdk/lib/io/http_headers.dart
|
| +++ b/sdk/lib/io/http_headers.dart
|
| @@ -405,6 +405,71 @@ class _HttpHeaders implements HttpHeaders {
|
| return sb.toString();
|
| }
|
|
|
| + List<Cookie> _parseCookies() {
|
| + // Parse a Cookie header value according to the rules in RFC 6265.
|
| + var cookies = new List<Cookie>();
|
| + void parseCookieString(String s) {
|
| + int index = 0;
|
| +
|
| + bool done() => index == s.length;
|
| +
|
| + void skipWS() {
|
| + while (!done()) {
|
| + if (s[index] != " " && s[index] != "\t") return;
|
| + index++;
|
| + }
|
| + }
|
| +
|
| + String parseName() {
|
| + int start = index;
|
| + while (!done()) {
|
| + if (s[index] == " " || s[index] == "\t" || s[index] == "=") break;
|
| + index++;
|
| + }
|
| + return s.substring(start, index).toLowerCase();
|
| + }
|
| +
|
| + String parseValue() {
|
| + int start = index;
|
| + while (!done()) {
|
| + if (s[index] == " " || s[index] == "\t" || s[index] == ";") break;
|
| + index++;
|
| + }
|
| + return s.substring(start, index).toLowerCase();
|
| + }
|
| +
|
| + void expect(String expected) {
|
| + if (done()) {
|
| + throw new HttpException("Failed to parse header value [$s]");
|
| + }
|
| + if (s[index] != expected) {
|
| + throw new HttpException("Failed to parse header value [$s]");
|
| + }
|
| + index++;
|
| + }
|
| +
|
| + while (!done()) {
|
| + skipWS();
|
| + if (done()) return;
|
| + String name = parseName();
|
| + skipWS();
|
| + expect("=");
|
| + skipWS();
|
| + String value = parseValue();
|
| + cookies.add(new _Cookie(name, value));
|
| + skipWS();
|
| + if (done()) return;
|
| + expect(";");
|
| + }
|
| + }
|
| + List<String> values = this["cookie"];
|
| + if (values != null) {
|
| + values.forEach((headerValue) => parseCookieString(headerValue));
|
| + }
|
| + return cookies;
|
| + }
|
| +
|
| +
|
| bool _mutable = true; // Are the headers currently mutable?
|
| Map<String, List<String>> _headers;
|
| List<String> _noFoldingHeaders;
|
|
|