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

Unified Diff: tests/standalone/src/io/HttpTest.dart

Issue 9602011: Add handling of HTTP header "Expires" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed accidental edit Created 8 years, 10 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
« runtime/bin/http_utils.dart ('K') | « tests/standalone/src/io/HttpDateTest.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/io/HttpTest.dart
diff --git a/tests/standalone/src/io/HttpTest.dart b/tests/standalone/src/io/HttpTest.dart
index 62c5bcdd0fad69e6ab791abfd748dd85b18d3289..b1782af6d72ffde9679315895aaa5042247a9233 100644
--- a/tests/standalone/src/io/HttpTest.dart
+++ b/tests/standalone/src/io/HttpTest.dart
@@ -124,6 +124,26 @@ class TestServer extends Isolate {
response.outputStream.close();
}
+ // Set the "Expires" header using the expires property.
+ void _expires1Handler(HttpRequest request, HttpResponse response) {
+ Date date =
+ new Date.withTimeZone(
+ 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc());
+ response.expires = date;
+ Expect.equals(date, response.expires);
+ response.outputStream.close();
+ }
+
+ // Set the "Expires" header.
+ void _expires2Handler(HttpRequest request, HttpResponse response) {
+ response.setHeader("Expires", "Fri, 11 Jun 1999 18:46:53 GMT");
+ Date date =
+ new Date.withTimeZone(
+ 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc());
+ Expect.equals(date, response.expires);
+ response.outputStream.close();
+ }
+
void main() {
// Setup request handlers.
_requestHandlers = new Map();
@@ -138,6 +158,14 @@ class TestServer extends Isolate {
(HttpRequest request, HttpResponse response) {
_reasonForMovingHandler(request, response);
};
+ _requestHandlers["/expires1"] =
+ (HttpRequest request, HttpResponse response) {
+ _expires1Handler(request, response);
+ };
+ _requestHandlers["/expires2"] =
+ (HttpRequest request, HttpResponse response) {
+ _expires2Handler(request, response);
+ };
this.port.receive((var message, SendPort replyTo) {
if (message.isStart) {
@@ -400,6 +428,41 @@ void testReasonPhrase() {
}
+void testExpires() {
+ TestServerMain testServerMain = new TestServerMain();
+ testServerMain.setServerStartedHandler((int port) {
+ int responses = 0;
+ HttpClient httpClient = new HttpClient();
+
+ void processResponse(HttpClientResponse response) {
+ Expect.equals(HttpStatus.OK, response.statusCode);
+ Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT",
+ response.headers["expires"]);
+ Expect.equals(
+ new Date.withTimeZone(
+ 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc()),
+ response.expires);
+ responses++;
+ if (responses == 2) {
+ httpClient.shutdown();
+ testServerMain.shutdown();
+ }
+ }
+
+ HttpClientConnection conn1 = httpClient.get("127.0.0.1", port, "/expires1");
+ conn1.onResponse = (HttpClientResponse response) {
+ processResponse(response);
+ };
+ HttpClientConnection conn2 = httpClient.get("127.0.0.1", port, "/expires2");
+ conn2.onResponse = (HttpClientResponse response) {
+ processResponse(response);
+ };
+ });
+
+ testServerMain.start();
+}
+
+
void main() {
testStartStop();
testGET();
@@ -411,4 +474,5 @@ void main() {
testReadShort(false);
test404();
testReasonPhrase();
+ testExpires();
}
« runtime/bin/http_utils.dart ('K') | « tests/standalone/src/io/HttpDateTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698