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

Unified Diff: runtime/bin/http_impl.dart

Issue 10191013: Add handling of the HTTP Date header (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/http.dart ('k') | tests/standalone/src/io/HttpHeadersTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/http_impl.dart
diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart
index ae9243af27be45418a69f3e261deb8e04e488f22..9a52ed8d7ea76c5de65c67b49513a0b1763a22ec 100644
--- a/runtime/bin/http_impl.dart
+++ b/runtime/bin/http_impl.dart
@@ -63,6 +63,24 @@ class _HttpHeaders implements HttpHeaders {
_updateHostHeader();
}
+ Date get date() {
+ List<String> values = _headers["date"];
+ if (values != null) {
+ try {
+ return _HttpUtils.parseDate(values[0]);
+ } catch (Exception e) {
+ return null;
+ }
+ }
Anders Johnsen 2012/04/25 09:02:09 Maybe add an explicit return null.
Søren Gjesse 2012/04/25 14:14:36 Done.
+ }
+
+ void set date(Date date) {
+ // Format "Date" header with date in Greenwich Mean Time (GMT).
+ String formatted =
+ _HttpUtils.formatDate(expires.changeTimeZone(new TimeZone.utc()));
+ _set("date", formatted);
+ }
+
Date get expires() {
List<String> values = _headers["expires"];
if (values != null) {
@@ -83,7 +101,15 @@ class _HttpHeaders implements HttpHeaders {
void _add(String name, Object value) {
// TODO(sgjesse): Add immutable state throw HttpException is immutable.
- if (name.toLowerCase() == "expires") {
+ if (name.toLowerCase() == "date") {
+ if (value is Date) {
+ date = value;
+ } else if (value is String) {
+ _set("date", value);
+ } else {
+ throw new HttpException("Unexpected type for header named $name");
+ }
+ } else if (name.toLowerCase() == "expires") {
if (value is Date) {
expires = value;
} else if (value is String) {
« no previous file with comments | « runtime/bin/http.dart ('k') | tests/standalone/src/io/HttpHeadersTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698