| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 class _HttpHeaders implements HttpHeaders { | 7 class _HttpHeaders implements HttpHeaders { |
| 8 _HttpHeaders(String this.protocolVersion) | 8 _HttpHeaders(String this.protocolVersion) |
| 9 : _headers = new Map<String, List<String>>(); | 9 : _headers = new Map<String, List<String>>(); |
| 10 | 10 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 sb.add(": "); | 398 sb.add(": "); |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 sb.add(values[i]); | 401 sb.add(values[i]); |
| 402 } | 402 } |
| 403 sb.add("\n"); | 403 sb.add("\n"); |
| 404 }); | 404 }); |
| 405 return sb.toString(); | 405 return sb.toString(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 List<Cookie> _parseCookies() { |
| 409 // Parse a Cookie header value according to the rules in RFC 6265. |
| 410 var cookies = new List<Cookie>(); |
| 411 void parseCookieString(String s) { |
| 412 int index = 0; |
| 413 |
| 414 bool done() => index == s.length; |
| 415 |
| 416 void skipWS() { |
| 417 while (!done()) { |
| 418 if (s[index] != " " && s[index] != "\t") return; |
| 419 index++; |
| 420 } |
| 421 } |
| 422 |
| 423 String parseName() { |
| 424 int start = index; |
| 425 while (!done()) { |
| 426 if (s[index] == " " || s[index] == "\t" || s[index] == "=") break; |
| 427 index++; |
| 428 } |
| 429 return s.substring(start, index).toLowerCase(); |
| 430 } |
| 431 |
| 432 String parseValue() { |
| 433 int start = index; |
| 434 while (!done()) { |
| 435 if (s[index] == " " || s[index] == "\t" || s[index] == ";") break; |
| 436 index++; |
| 437 } |
| 438 return s.substring(start, index).toLowerCase(); |
| 439 } |
| 440 |
| 441 void expect(String expected) { |
| 442 if (done()) { |
| 443 throw new HttpException("Failed to parse header value [$s]"); |
| 444 } |
| 445 if (s[index] != expected) { |
| 446 throw new HttpException("Failed to parse header value [$s]"); |
| 447 } |
| 448 index++; |
| 449 } |
| 450 |
| 451 while (!done()) { |
| 452 skipWS(); |
| 453 if (done()) return; |
| 454 String name = parseName(); |
| 455 skipWS(); |
| 456 expect("="); |
| 457 skipWS(); |
| 458 String value = parseValue(); |
| 459 cookies.add(new _Cookie(name, value)); |
| 460 skipWS(); |
| 461 if (done()) return; |
| 462 expect(";"); |
| 463 } |
| 464 } |
| 465 List<String> values = this["cookie"]; |
| 466 if (values != null) { |
| 467 values.forEach((headerValue) => parseCookieString(headerValue)); |
| 468 } |
| 469 return cookies; |
| 470 } |
| 471 |
| 472 |
| 408 bool _mutable = true; // Are the headers currently mutable? | 473 bool _mutable = true; // Are the headers currently mutable? |
| 409 Map<String, List<String>> _headers; | 474 Map<String, List<String>> _headers; |
| 410 List<String> _noFoldingHeaders; | 475 List<String> _noFoldingHeaders; |
| 411 | 476 |
| 412 int _contentLength = -1; | 477 int _contentLength = -1; |
| 413 bool _chunkedTransferEncoding = false; | 478 bool _chunkedTransferEncoding = false; |
| 414 final String protocolVersion; | 479 final String protocolVersion; |
| 415 String _host; | 480 String _host; |
| 416 int _port; | 481 int _port; |
| 417 } | 482 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 | 773 |
| 709 String name; | 774 String name; |
| 710 String value; | 775 String value; |
| 711 Date expires; | 776 Date expires; |
| 712 int maxAge; | 777 int maxAge; |
| 713 String domain; | 778 String domain; |
| 714 String path; | 779 String path; |
| 715 bool httpOnly = false; | 780 bool httpOnly = false; |
| 716 bool secure = false; | 781 bool secure = false; |
| 717 } | 782 } |
| OLD | NEW |