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

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: Addressed review comments Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/http.dart ('k') | runtime/bin/http_utils.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 04620df015ba749ab30cf442ff333a616b012bce..9a3d9df04ae621bf7701a7dff12c689b6ee7c84a 100644
--- a/runtime/bin/http_impl.dart
+++ b/runtime/bin/http_impl.dart
@@ -61,7 +61,7 @@ class _HttpRequestResponseBase {
Map get headers() => _headers;
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) throw new HttpException("Header already sent");
+ _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;
}
@@ -766,7 +781,7 @@ class _HttpClientRequest
_updateHostHeader() {
String portPart = _port == HttpClient.DEFAULT_HTTP_PORT ? "" : ":$_port";
- _setHeader("host", "$host$portPart");
+ _setHeader("Host", "$host$portPart");
}
// Delegate functions for the HttpOutputStream implementation.
@@ -855,6 +870,14 @@ 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() {
if (_inputStream == null) {
_inputStream = new _HttpInputStream(this);
« no previous file with comments | « runtime/bin/http.dart ('k') | runtime/bin/http_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698