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

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

Issue 11411121: Generate an error for active connections when the HTTP client is shutdown (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed long line Created 8 years, 1 month 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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:isolate"); 6 #import("dart:isolate");
7 #import("dart:io"); 7 #import("dart:io");
8 #import("dart:uri"); 8 #import("dart:uri");
9 9
10 void testHttp10Close(bool closeRequest) { 10 void testHttp10Close(bool closeRequest) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 }; 59 };
60 60
61 var client = new HttpClient(); 61 var client = new HttpClient();
62 var connection = 62 var connection =
63 client.getUrl(new Uri.fromString("http://127.0.0.1:${server.port}")); 63 client.getUrl(new Uri.fromString("http://127.0.0.1:${server.port}"));
64 connection.onResponse = (resp) { 64 connection.onResponse = (resp) {
65 int bytes = 0; 65 int bytes = 0;
66 resp.inputStream.onData = () { 66 resp.inputStream.onData = () {
67 bytes += resp.inputStream.read().length; 67 bytes += resp.inputStream.read().length;
68 if (bytes > 100) { 68 if (bytes > 100) {
69 client.shutdown(); 69 client.shutdown(force: true);
70 } 70 }
71 }; 71 };
72 }; 72 };
73 connection.onError = (e) => Expect.isTrue(e is HttpException);
73 } 74 }
74 75
75 main() { 76 main() {
76 testHttp10Close(false); 77 testHttp10Close(false);
77 testHttp10Close(true); 78 testHttp10Close(true);
78 testHttp11Close(false); 79 testHttp11Close(false);
79 testHttp11Close(true); 80 testHttp11Close(true);
80 testStreamResponse(); 81 testStreamResponse();
81 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698