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

Side by Side Diff: tests/standalone/io/http_stream_close_test.dart

Issue 11853011: Reapply "Add onClosed callbacks to HTTP output streams"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed debug print Created 7 years, 11 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
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 //
Mads Ager (google) 2013/01/11 12:09:12 Remove this line?
5
6 import "dart:io";
7 import "dart:uri";
8
9 main() {
10 bool serverOnClosed = false;
11 bool clientOnClosed = false;
12 bool requestOnClosed = false;
13
14 var server = new HttpServer();
15 var client = new HttpClient();
16
17 checkDone() {
18 if (serverOnClosed && clientOnClosed && requestOnClosed) {
19 server.close();
20 client.shutdown();
21 }
22 }
23
24 server.listen("127.0.0.1", 0);
25 server.defaultRequestHandler = (request, response) {
26 request.inputStream.onData = request.inputStream.read;
27 request.inputStream.onClosed = () {
28 response.outputStream.onClosed = () {
29 serverOnClosed = true;
30 checkDone();
31 };
32 response.outputStream.writeString("hello!");
33 response.outputStream.close();
34 };
35 };
36
37 var connection = client.postUrl(new Uri.fromString("http://127.0.0.1:${server. port}"));
Mads Ager (google) 2013/01/11 12:09:12 Line line.
38 connection.onError = (e) => throw e;
39 connection.onRequest = (request) {
40 request.contentLength = "hello!".length;
41 request.outputStream.onError = (e) => throw e;
42 request.outputStream.onClosed = () {
43 clientOnClosed = true;
44 checkDone();
45 };
46 request.outputStream.writeString("hello!");
47 request.outputStream.close();
48 };
49 connection.onResponse = (response) {
50 response.inputStream.onData = response.inputStream.read;
51 response.inputStream.onClosed = () {
52 requestOnClosed = true;
53 checkDone();
54 };
55 };
56 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698