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

Side by Side Diff: runtime/bin/http_impl.dart

Issue 10411057: Deprecate use of timezones. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 class _HttpHeaders implements HttpHeaders { 5 class _HttpHeaders implements HttpHeaders {
6 _HttpHeaders() : _headers = new Map<String, List<String>>(); 6 _HttpHeaders() : _headers = new Map<String, List<String>>();
7 7
8 List<String> operator[](String name) { 8 List<String> operator[](String name) {
9 name = name.toLowerCase(); 9 name = name.toLowerCase();
10 return _headers[name]; 10 return _headers[name];
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } catch (Exception e) { 83 } catch (Exception e) {
84 return null; 84 return null;
85 } 85 }
86 } 86 }
87 return null; 87 return null;
88 } 88 }
89 89
90 void set date(Date date) { 90 void set date(Date date) {
91 _checkMutable(); 91 _checkMutable();
92 // Format "Date" header with date in Greenwich Mean Time (GMT). 92 // Format "Date" header with date in Greenwich Mean Time (GMT).
93 String formatted = 93 String formatted = _HttpUtils.formatDate(expires.toUtc());
94 _HttpUtils.formatDate(expires.changeTimeZone(new TimeZone.utc()));
95 _set("date", formatted); 94 _set("date", formatted);
96 } 95 }
97 96
98 Date get expires() { 97 Date get expires() {
99 List<String> values = _headers["expires"]; 98 List<String> values = _headers["expires"];
100 if (values != null) { 99 if (values != null) {
101 try { 100 try {
102 return _HttpUtils.parseDate(values[0]); 101 return _HttpUtils.parseDate(values[0]);
103 } catch (Exception e) { 102 } catch (Exception e) {
104 return null; 103 return null;
105 } 104 }
106 } 105 }
107 return null; 106 return null;
108 } 107 }
109 108
110 void set expires(Date expires) { 109 void set expires(Date expires) {
111 _checkMutable(); 110 _checkMutable();
112 // Format "Expires" header with date in Greenwich Mean Time (GMT). 111 // Format "Expires" header with date in Greenwich Mean Time (GMT).
113 String formatted = 112 String formatted = _HttpUtils.formatDate(expires.toUtc());
114 _HttpUtils.formatDate(expires.changeTimeZone(new TimeZone.utc()));
115 _set("expires", formatted); 113 _set("expires", formatted);
116 } 114 }
117 115
118 void _add(String name, Object value) { 116 void _add(String name, Object value) {
119 // TODO(sgjesse): Add immutable state throw HttpException is immutable. 117 // TODO(sgjesse): Add immutable state throw HttpException is immutable.
120 if (name.toLowerCase() == "date") { 118 if (name.toLowerCase() == "date") {
121 if (value is Date) { 119 if (value is Date) {
122 date = value; 120 date = value;
123 } else if (value is String) { 121 } else if (value is String) {
124 _set("date", value); 122 _set("date", value);
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 1645
1648 1646
1649 class _RedirectInfo implements RedirectInfo { 1647 class _RedirectInfo implements RedirectInfo {
1650 const _RedirectInfo(int this.statusCode, 1648 const _RedirectInfo(int this.statusCode,
1651 String this.method, 1649 String this.method,
1652 Uri this.location); 1650 Uri this.location);
1653 final int statusCode; 1651 final int statusCode;
1654 final String method; 1652 final String method;
1655 final Uri location; 1653 final Uri location;
1656 } 1654 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698