| 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;
|
|
|