OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 import "dart:isolate"; | 7 import "dart:isolate"; |
8 import "dart:typeddata"; | 8 import "dart:typeddata"; |
9 | 9 |
10 void testClientRequest(void handler(request)) { | 10 void testClientRequest(void handler(request)) { |
(...skipping 11 matching lines...) Expand all Loading... |
22 }) | 22 }) |
23 .then((response) { | 23 .then((response) { |
24 response.listen((_) {}, onDone: () { | 24 response.listen((_) {}, onDone: () { |
25 client.close(); | 25 client.close(); |
26 server.close(); | 26 server.close(); |
27 }); | 27 }); |
28 }) | 28 }) |
29 .catchError((error) { | 29 .catchError((error) { |
30 server.close(); | 30 server.close(); |
31 client.close(); | 31 client.close(); |
32 }, test: (e) => e is HttpParserException); | 32 }); |
33 }); | 33 }); |
34 } | 34 } |
35 | 35 |
36 void testResponseDone() { | 36 void testResponseDone() { |
37 testClientRequest((request) { | 37 testClientRequest((request) { |
38 request.close(); | 38 request.close(); |
39 request.done.then((req) { | 39 request.done.then((res1) { |
40 Expect.equals(request, req); | 40 request.response.then((res2) { |
| 41 Expect.equals(res1, res2); |
| 42 }); |
41 }); | 43 }); |
42 return request.response; | 44 return request.response; |
43 }); | 45 }); |
44 } | 46 } |
45 | 47 |
46 void testBadResponseAdd() { | 48 void testBadResponseAdd() { |
47 testClientRequest((request) { | 49 testClientRequest((request) { |
48 var port = new ReceivePort(); | 50 var port = new ReceivePort(); |
49 request.contentLength = 0; | 51 request.contentLength = 0; |
50 request.writeBytes([0]); | 52 request.writeBytes([0]); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 }, test: (e) => e is HttpException); | 104 }, test: (e) => e is HttpException); |
103 return request.response; | 105 return request.response; |
104 }); | 106 }); |
105 } | 107 } |
106 | 108 |
107 void main() { | 109 void main() { |
108 testResponseDone(); | 110 testResponseDone(); |
109 testBadResponseAdd(); | 111 testBadResponseAdd(); |
110 testBadResponseClose(); | 112 testBadResponseClose(); |
111 } | 113 } |
OLD | NEW |