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

Side by Side Diff: sdk/lib/io/http_headers.dart

Issue 12425004: Fix deprecation warnings in dart:io. Now completely warning free. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/file.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 388 }
389 buffer[bufferPos++] = _CharCode.CR; 389 buffer[bufferPos++] = _CharCode.CR;
390 buffer[bufferPos++] = _CharCode.LF; 390 buffer[bufferPos++] = _CharCode.LF;
391 }); 391 });
392 writeBuffer(); 392 writeBuffer();
393 } 393 }
394 394
395 String toString() { 395 String toString() {
396 StringBuffer sb = new StringBuffer(); 396 StringBuffer sb = new StringBuffer();
397 _headers.forEach((String name, List<String> values) { 397 _headers.forEach((String name, List<String> values) {
398 sb.add(name); 398 sb.write(name);
399 sb.add(": "); 399 sb.write(": ");
400 bool fold = _foldHeader(name); 400 bool fold = _foldHeader(name);
401 for (int i = 0; i < values.length; i++) { 401 for (int i = 0; i < values.length; i++) {
402 if (i > 0) { 402 if (i > 0) {
403 if (fold) { 403 if (fold) {
404 sb.add(", "); 404 sb.write(", ");
405 } else { 405 } else {
406 sb.add("\n"); 406 sb.write("\n");
407 sb.add(name); 407 sb.write(name);
408 sb.add(": "); 408 sb.write(": ");
409 } 409 }
410 } 410 }
411 sb.add(values[i]); 411 sb.write(values[i]);
412 } 412 }
413 sb.add("\n"); 413 sb.write("\n");
414 }); 414 });
415 return sb.toString(); 415 return sb.toString();
416 } 416 }
417 417
418 List<Cookie> _parseCookies() { 418 List<Cookie> _parseCookies() {
419 // Parse a Cookie header value according to the rules in RFC 6265. 419 // Parse a Cookie header value according to the rules in RFC 6265.
420 var cookies = new List<Cookie>(); 420 var cookies = new List<Cookie>();
421 void parseCookieString(String s) { 421 void parseCookieString(String s) {
422 int index = 0; 422 int index = 0;
423 423
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 _parse(value); 500 _parse(value);
501 } 501 }
502 502
503 Map<String, String> get parameters { 503 Map<String, String> get parameters {
504 if (_parameters == null) _parameters = new Map<String, String>(); 504 if (_parameters == null) _parameters = new Map<String, String>();
505 return _parameters; 505 return _parameters;
506 } 506 }
507 507
508 String toString() { 508 String toString() {
509 StringBuffer sb = new StringBuffer(); 509 StringBuffer sb = new StringBuffer();
510 sb.add(value); 510 sb.write(value);
511 if (parameters != null && parameters.length > 0) { 511 if (parameters != null && parameters.length > 0) {
512 _parameters.forEach((String name, String value) { 512 _parameters.forEach((String name, String value) {
513 sb.add("; "); 513 sb.write("; ");
514 sb.add(name); 514 sb.write(name);
515 sb.add("="); 515 sb.write("=");
516 sb.add(value); 516 sb.write(value);
517 }); 517 });
518 } 518 }
519 return sb.toString(); 519 return sb.toString();
520 } 520 }
521 521
522 void _parse(String s) { 522 void _parse(String s) {
523 int index = 0; 523 int index = 0;
524 524
525 bool done() => index == s.length; 525 bool done() => index == s.length;
526 526
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 while (!done()) { 573 while (!done()) {
574 if (s[index] == "\\") { 574 if (s[index] == "\\") {
575 if (index + 1 == s.length) { 575 if (index + 1 == s.length) {
576 throw new HttpException("Failed to parse header value"); 576 throw new HttpException("Failed to parse header value");
577 } 577 }
578 index++; 578 index++;
579 } else if (s[index] == "\"") { 579 } else if (s[index] == "\"") {
580 index++; 580 index++;
581 break; 581 break;
582 } 582 }
583 sb.add(s[index]); 583 sb.write(s[index]);
584 index++; 584 index++;
585 } 585 }
586 return sb.toString(); 586 return sb.toString();
587 } else { 587 } else {
588 // Parse non-quoted value. 588 // Parse non-quoted value.
589 return parseValue(); 589 return parseValue();
590 } 590 }
591 } 591 }
592 592
593 while (!done()) { 593 while (!done()) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 750 }
751 index++; // Skip the = character. 751 index++; // Skip the = character.
752 value = parseValue(); 752 value = parseValue();
753 if (done()) return; 753 if (done()) return;
754 index++; // Skip the ; character. 754 index++; // Skip the ; character.
755 parseAttributes(); 755 parseAttributes();
756 } 756 }
757 757
758 String toString() { 758 String toString() {
759 StringBuffer sb = new StringBuffer(); 759 StringBuffer sb = new StringBuffer();
760 sb.add(name); 760 sb.write(name);
761 sb.add("="); 761 sb.write("=");
762 sb.add(value); 762 sb.write(value);
763 if (expires != null) { 763 if (expires != null) {
764 sb.add("; Expires="); 764 sb.write("; Expires=");
765 sb.add(_HttpUtils.formatDate(expires)); 765 sb.write(_HttpUtils.formatDate(expires));
766 } 766 }
767 if (maxAge != null) { 767 if (maxAge != null) {
768 sb.add("; Max-Age="); 768 sb.write("; Max-Age=");
769 sb.add(maxAge); 769 sb.write(maxAge);
770 } 770 }
771 if (domain != null) { 771 if (domain != null) {
772 sb.add("; Domain="); 772 sb.write("; Domain=");
773 sb.add(domain); 773 sb.write(domain);
774 } 774 }
775 if (path != null) { 775 if (path != null) {
776 sb.add("; Path="); 776 sb.write("; Path=");
777 sb.add(path); 777 sb.write(path);
778 } 778 }
779 if (secure) sb.add("; Secure"); 779 if (secure) sb.write("; Secure");
780 if (httpOnly) sb.add("; HttpOnly"); 780 if (httpOnly) sb.write("; HttpOnly");
781 return sb.toString(); 781 return sb.toString();
782 } 782 }
783 783
784 String name; 784 String name;
785 String value; 785 String value;
786 DateTime expires; 786 DateTime expires;
787 int maxAge; 787 int maxAge;
788 String domain; 788 String domain;
789 String path; 789 String path;
790 bool httpOnly = false; 790 bool httpOnly = false;
791 bool secure = false; 791 bool secure = false;
792 } 792 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698