| 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 "dart:io"; | 5 import "dart:io"; |
| 6 import "dart:isolate"; | 6 import "dart:isolate"; |
| 7 import "dart:scalarlist"; | 7 import "dart:scalarlist"; |
| 8 | 8 |
| 9 void testClientRequest(void handler(request)) { | 9 void testClientRequest(void handler(request)) { |
| 10 HttpServer.bind().then((server) { | 10 HttpServer.bind().then((server) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 }); | 40 }); |
| 41 return request.response; | 41 return request.response; |
| 42 }); | 42 }); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void testBadResponseAdd() { | 45 void testBadResponseAdd() { |
| 46 testClientRequest((request) { | 46 testClientRequest((request) { |
| 47 var port = new ReceivePort(); | 47 var port = new ReceivePort(); |
| 48 request.contentLength = 0; | 48 request.contentLength = 0; |
| 49 request.writeBytes([0]); | 49 request.writeBytes([0]); |
| 50 request.close(); |
| 50 request.done.catchError((error) { | 51 request.done.catchError((error) { |
| 51 port.close(); | 52 port.close(); |
| 52 }, test: (e) => e is HttpException); | 53 }, test: (e) => e is HttpException); |
| 53 return request.response; | 54 return request.response; |
| 54 }); | 55 }); |
| 55 | 56 |
| 56 testClientRequest((request) { | 57 testClientRequest((request) { |
| 57 var port = new ReceivePort(); | 58 var port = new ReceivePort(); |
| 58 request.contentLength = 5; | 59 request.contentLength = 5; |
| 59 request.writeBytes([0, 0, 0]); | 60 request.writeBytes([0, 0, 0]); |
| 60 request.writeBytes([0, 0, 0]); | 61 request.writeBytes([0, 0, 0]); |
| 62 request.close(); |
| 61 request.done.catchError((error) { | 63 request.done.catchError((error) { |
| 62 port.close(); | 64 port.close(); |
| 63 }, test: (e) => e is HttpException); | 65 }, test: (e) => e is HttpException); |
| 64 return request.response; | 66 return request.response; |
| 65 }); | 67 }); |
| 66 | 68 |
| 67 testClientRequest((request) { | 69 testClientRequest((request) { |
| 68 var port = new ReceivePort(); | 70 var port = new ReceivePort(); |
| 69 request.contentLength = 0; | 71 request.contentLength = 0; |
| 70 request.writeBytes(new Uint8List(64 * 1024)); | 72 request.writeBytes(new Uint8List(64 * 1024)); |
| 71 request.writeBytes(new Uint8List(64 * 1024)); | 73 request.writeBytes(new Uint8List(64 * 1024)); |
| 72 request.writeBytes(new Uint8List(64 * 1024)); | 74 request.writeBytes(new Uint8List(64 * 1024)); |
| 75 request.close(); |
| 73 request.done.catchError((error) { | 76 request.done.catchError((error) { |
| 74 port.close(); | 77 port.close(); |
| 75 }, test: (e) => e is HttpException); | 78 }, test: (e) => e is HttpException); |
| 76 return request.response; | 79 return request.response; |
| 77 }); | 80 }); |
| 78 } | 81 } |
| 79 | 82 |
| 80 void testBadResponseClose() { | 83 void testBadResponseClose() { |
| 81 testClientRequest((request) { | 84 testClientRequest((request) { |
| 82 var port = new ReceivePort(); | 85 var port = new ReceivePort(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 }, test: (e) => e is HttpException); | 101 }, test: (e) => e is HttpException); |
| 99 return request.response; | 102 return request.response; |
| 100 }); | 103 }); |
| 101 } | 104 } |
| 102 | 105 |
| 103 void main() { | 106 void main() { |
| 104 testResponseDone(); | 107 testResponseDone(); |
| 105 testBadResponseAdd(); | 108 testBadResponseAdd(); |
| 106 testBadResponseClose(); | 109 testBadResponseClose(); |
| 107 } | 110 } |
| OLD | NEW |