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..043ed655cc1c3b05ea2736550d661b18b7b79701 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,36 @@ void main() { |
| }); |
| }); |
| }); |
| + |
| + group('date header', () { |
| + test('is sent by default', () { |
| + _scheduleServer(syncHandler); |
| + |
| + return _scheduleGet().then((response) { |
| + expect(response.headers, contains('date')); |
| + var responseDate = parser.parseHttpDate(response.headers['date']); |
| + |
| + var nowEpoch = new DateTime.now().toUtc().millisecondsSinceEpoch; |
| + expect(responseDate.millisecondsSinceEpoch, |
| + inInclusiveRange(nowEpoch - 1000, nowEpoch)); |
|
nweiz
2014/05/27 19:52:44
This is potentially flaky. Instead of assuming the
kevmoo
2014/05/27 20:50:58
Done. I have to add in some rounding to account fo
|
| + }); |
| + }); |
| + |
| + 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) |
|
nweiz
2014/05/27 19:52:44
Nit: I don't like using HttpHeaders over just a he
kevmoo
2014/05/27 20:50:58
We're already using it in shelf_io. Eh...
|
| + }); |
| + }); |
| + |
| + return _scheduleGet().then((response) { |
| + expect(response.headers, contains('date')); |
| + var responseDate = parser.parseHttpDate(response.headers['date']); |
| + expect(responseDate, date); |
| + }); |
| + }); |
| + }); |
| } |
| int _serverPort; |