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

Side by Side Diff: tests/standalone/src/io/HttpServerEarlyClientCloseTest.dart

Issue 9956062: Refactor the close and error handling of HTTP connections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #import("dart:io"); 1 #import("dart:io");
2 #import("dart:isolate"); 2 #import("dart:isolate");
3 3
4 void sendData(List<int> data, int port) { 4 void sendData(List<int> data, int port) {
5 Socket socket = new Socket("127.0.0.1", port); 5 Socket socket = new Socket("127.0.0.1", port);
6 socket.onConnect = () { 6 socket.onConnect = () {
7 socket.onData = () { 7 socket.onData = () {
8 Expect.fail("No data response was expected"); 8 Expect.fail("No data response was expected");
9 }; 9 };
10 socket.outputStream.onNoPendingWrites = () { 10 socket.outputStream.onNoPendingWrites = () {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 void testEarlyClose() { 53 void testEarlyClose() {
54 List<EarlyCloseTest> tests = new List<EarlyCloseTest>(); 54 List<EarlyCloseTest> tests = new List<EarlyCloseTest>();
55 void add(Object data, String exception, [bool expectRequest = false]) { 55 void add(Object data, String exception, [bool expectRequest = false]) {
56 tests.add(new EarlyCloseTest(data, exception, expectRequest)); 56 tests.add(new EarlyCloseTest(data, exception, expectRequest));
57 } 57 }
58 // The empty packet is valid. 58 // The empty packet is valid.
59 59
60 // Close while sending header 60 // Close while sending header
61 add("G", "Connection closed before header was received"); 61 add("G", "Connection closed before full header was received");
62 add("GET /", "Failed to parse HTTP"); 62 add("GET /", "Connection closed before full header was received");
63 add("GET / HTTP/1.1", "Failed to parse HTTP"); 63 add("GET / HTTP/1.1", "Connection closed before full header was received");
64 add("GET / HTTP/1.1\r\n", "Failed to parse HTTP"); 64 add("GET / HTTP/1.1\r\n", "Connection closed before full header was received") ;
65 65
66 // Close while sending content 66 // Close while sending content
67 add("GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\n", 67 add("GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\n",
68 "Failed to parse HTTP", 68 "Connection closed before full body was received",
69 expectRequest: true); 69 expectRequest: true);
70 add("GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\n1", 70 add("GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\n1",
71 "Failed to parse HTTP", 71 "Connection closed before full body was received",
72 expectRequest: true); 72 expectRequest: true);
73 73
74 74
75 HttpServer server = new HttpServer(); 75 HttpServer server = new HttpServer();
76 server.listen("127.0.0.1", 0); 76 server.listen("127.0.0.1", 0);
77 void runTest(Iterator it) { 77 void runTest(Iterator it) {
78 if (it.hasNext()) { 78 if (it.hasNext()) {
79 it.next().execute(server).then((_) => runTest(it)); 79 it.next().execute(server).then((_) => runTest(it));
80 } else { 80 } else {
81 server.close(); 81 server.close();
82 } 82 }
83 } 83 }
84 runTest(tests.iterator()); 84 runTest(tests.iterator());
85 } 85 }
86 86
87 void main() { 87 void main() {
88 testEarlyClose(); 88 testEarlyClose();
89 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698