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

Unified Diff: pkg/shelf/test/shelf_io_test.dart

Issue 300023003: pkg/shelf - send Date header in shelf_io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: final tweaks Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/test/shelf_io_test.dart
diff --git a/pkg/shelf/test/shelf_io_test.dart b/pkg/shelf/test/shelf_io_test.dart
index 520565809d0b95a7b3baef7ea9d990daca3a6744..c7d9f7a78d5ea449d2fda53bee17fb9703db65dc 100644
--- a/pkg/shelf/test/shelf_io_test.dart
+++ b/pkg/shelf/test/shelf_io_test.dart
@@ -9,6 +9,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
+import 'package:http_parser/http_parser.dart' as parser;
import 'package:scheduled_test/scheduled_test.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as shelf_io;
@@ -249,6 +250,40 @@ void main() {
});
});
});
+
+ group('date header', () {
+ test('is sent by default', () {
+ _scheduleServer(syncHandler);
+
+ // Update beforeRequest to be one second earlier. HTTP dates only have
+ // second-level granularity and the request will likely take less than a
+ // second.
+ var beforeRequest = new DateTime.now().subtract(new Duration(seconds: 1));
+
+ return _scheduleGet().then((response) {
+ expect(response.headers, contains('date'));
+ var responseDate = parser.parseHttpDate(response.headers['date']);
+
+ expect(responseDate.isAfter(beforeRequest), isTrue);
+ expect(responseDate.isBefore(new DateTime.now()), isTrue);
+ });
+ });
+
+ test('defers to header in response', () {
+ var date = new DateTime.utc(1981, 6, 5);
+ _scheduleServer((request) {
+ return new Response.ok('test', headers: {
+ HttpHeaders.DATE: parser.formatHttpDate(date)
+ });
+ });
+
+ return _scheduleGet().then((response) {
+ expect(response.headers, contains('date'));
+ var responseDate = parser.parseHttpDate(response.headers['date']);
+ expect(responseDate, date);
+ });
+ });
+ });
}
int _serverPort;
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698