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

Side by Side Diff: tests/standalone/io/http_connection_header_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 8
9 void setConnectionHeaders(HttpHeaders headers) { 9 void setConnectionHeaders(HttpHeaders headers) {
10 headers.add(HttpHeaders.CONNECTION, "my-connection-header1"); 10 headers.add(HttpHeaders.CONNECTION, "my-connection-header1");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 conn.onError = (e) => Expect.fail("Unexpected error $e"); 57 conn.onError = (e) => Expect.fail("Unexpected error $e");
58 conn.onRequest = (HttpClientRequest request) { 58 conn.onRequest = (HttpClientRequest request) {
59 setConnectionHeaders(request.headers); 59 setConnectionHeaders(request.headers);
60 request.persistentConnection = clientPersistentConnection; 60 request.persistentConnection = clientPersistentConnection;
61 request.outputStream.close(); 61 request.outputStream.close();
62 }; 62 };
63 conn.onResponse = (HttpClientResponse response) { 63 conn.onResponse = (HttpClientResponse response) {
64 Expect.isFalse(response.persistentConnection); 64 Expect.isFalse(response.persistentConnection);
65 checkExpectedConnectionHeaders(response.headers, 65 checkExpectedConnectionHeaders(response.headers,
66 response.persistentConnection); 66 response.persistentConnection);
67 count++; 67 response.inputStream.onClosed = () {
68 if (count == totalConnections) { 68 count++;
69 client.shutdown(); 69 if (count == totalConnections) {
70 server.close(); 70 client.shutdown();
71 } 71 server.close();
72 }
73 };
72 }; 74 };
73 } 75 }
74 } 76 }
75 77
76 78
77 void main() { 79 void main() {
78 test(2, false); 80 test(2, false);
79 test(2, true); 81 test(2, true);
80 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698