Chromium Code Reviews| 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..9f921d71a35eeb212654a58e74bd71ae49917314 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,39 @@ void main() { |
| }); |
| }); |
| }); |
| + |
| + group('date header', () { |
| + test('is sent by default', () { |
| + _scheduleServer(syncHandler); |
| + |
| + // update beforeRequest to be one second earlier. Accounts for second |
|
nweiz
2014/05/27 21:06:47
"update" -> "Update"
"Accounts for second resolut
kevmoo
2014/05/27 21:10:59
Done.
|
| + // resolution in HTTP Date. |
| + 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; |