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 | 5 |
6 import "dart:io"; | 6 import "dart:io"; |
7 import "dart:uri"; | 7 import "dart:uri"; |
8 | 8 |
9 main() { | 9 main() { |
10 bool serverOnClosed = false; | 10 bool serverOnClosed = false; |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 server.listen((request) { | 24 server.listen((request) { |
25 request.listen( | 25 request.listen( |
26 (_) {}, | 26 (_) {}, |
27 onDone: () { | 27 onDone: () { |
28 request.response.done.then((_) { | 28 request.response.done.then((_) { |
29 serverOnClosed = true; | 29 serverOnClosed = true; |
30 checkDone(); | 30 checkDone(); |
31 }); | 31 }); |
32 request.response.addString("hello!"); | 32 request.response.write("hello!"); |
33 request.response.close(); | 33 request.response.close(); |
34 }); | 34 }); |
35 }); | 35 }); |
36 | 36 |
37 client.postUrl(Uri.parse("http://127.0.0.1:${server.port}")) | 37 client.postUrl(Uri.parse("http://127.0.0.1:${server.port}")) |
38 .then((request) { | 38 .then((request) { |
39 request.contentLength = "hello!".length; | 39 request.contentLength = "hello!".length; |
40 request.done.then((_) { | 40 request.done.then((_) { |
41 clientOnClosed = true; | 41 clientOnClosed = true; |
42 checkDone(); | 42 checkDone(); |
43 }); | 43 }); |
44 request.addString("hello!"); | 44 request.write("hello!"); |
45 return request.close(); | 45 return request.close(); |
46 }) | 46 }) |
47 .then((response) { | 47 .then((response) { |
48 response.listen( | 48 response.listen( |
49 (_) {}, | 49 (_) {}, |
50 onDone: () { | 50 onDone: () { |
51 requestOnClosed = true; | 51 requestOnClosed = true; |
52 checkDone(); | 52 checkDone(); |
53 }); | 53 }); |
54 }); | 54 }); |
55 }); | 55 }); |
56 } | 56 } |
OLD | NEW |