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

Unified Diff: runtime/bin/http_impl.dart

Issue 9602011: Add handling of HTTP header "Expires" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed accidental edit Created 8 years, 10 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
Index: runtime/bin/http_impl.dart
diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart
index 4bc975f9a5828037b58bd27b32ae77cd927ff6dc..e30901a0daaa99539419013c0c630729bfb4e5db 100644
--- a/runtime/bin/http_impl.dart
+++ b/runtime/bin/http_impl.dart
@@ -60,7 +60,7 @@ class _HttpRequestResponseBase {
bool get keepAlive() => _keepAlive;
void _setHeader(String name, String value) {
- _headers[name] = value;
+ _headers[name.toLowerCase()] = value;
}
bool _write(List<int> data, bool copyBuffer) {
@@ -280,11 +280,25 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
_reasonPhrase = reasonPhrase;
}
+ Date get expires() => _expires;
+ void set expires(Date expires) {
+ if (_outputStream != null) return new HttpException("Header already sent");
Anders Johnsen 2012/03/06 10:41:01 throw
Søren Gjesse 2012/03/06 12:01:16 Done.
+ _expires = expires;
+ // Format "Expires" header with date in Greenwich Mean Time (GMT).
+ String formatted =
+ _HttpUtils.formatDate(_expires.changeTimeZone(new TimeZone.utc()));
+ _setHeader("Expires", formatted);
+ }
+
// Set a header on the response. NOTE: If the same header is set
// more than once only the last one will be part of the response.
void setHeader(String name, String value) {
if (_outputStream != null) return new HttpException("Header already sent");
- _setHeader(name, value);
+ if (name.toLowerCase() == "expires") {
+ expires = _HttpUtils.parseDate(value);
+ } else {
+ _setHeader(name, value);
+ }
}
OutputStream get outputStream() {
@@ -431,6 +445,7 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
// Response status code.
int _statusCode;
String _reasonPhrase;
+ Date _expires;
_HttpOutputStream _outputStream;
int _state;
}
@@ -818,6 +833,13 @@ class _HttpClientResponse
int get statusCode() => _statusCode;
String get reasonPhrase() => _reasonPhrase;
+
+ Date get expires() {
+ String str = _headers["expires"];
+ if (str == null) return null;
+ return _HttpUtils.parseDate(str);
+ }
+
Map get headers() => _headers;
InputStream get inputStream() {
« no previous file with comments | « runtime/bin/http.dart ('k') | runtime/bin/http_utils.dart » ('j') | runtime/bin/http_utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698