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

Unified Diff: tests/standalone/io/http_detach_socket_test.dart

Issue 308923002: When a connection is upgraded, don't return it as idle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_detach_socket_test.dart
diff --git a/tests/standalone/io/http_detach_socket_test.dart b/tests/standalone/io/http_detach_socket_test.dart
index e5669d659b0bafb0b1e4956d517a81a2764c2eed..033a474b2a18b883edc64e48ee28318537d444e6 100644
--- a/tests/standalone/io/http_detach_socket_test.dart
+++ b/tests/standalone/io/http_detach_socket_test.dart
@@ -8,6 +8,7 @@
// VMOptions=--short_socket_read --short_socket_write
import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
import "dart:io";
import "dart:isolate";
@@ -145,9 +146,60 @@ void testClientDetachSocket() {
});
}
+void testUpgradedConnection() {
+ asyncStart();
+ HttpServer.bind("127.0.0.1", 0).then((server) {
+ server.listen((request) {
+ request.response.headers.set('connection', 'upgrade');
+ if (request.headers.value('upgrade') == 'mine') {
+ asyncStart();
+ request.response.detachSocket().then((socket) {
+ socket.pipe(socket).then((_) {
+ asyncEnd();
+ });
+ });
+ } else {
+ request.response.close();
+ }
+ });
+
+ var client = new HttpClient();
+ client.userAgent = null;
+ client.get("127.0.0.1", server.port, "/")
+ .then((request) {
+ request.headers.set('upgrade', 'mine');
+ return request.close();
+ })
+ .then((response) {
+ client.get("127.0.0.1", server.port, "/")
+ .then((request) {
+ response.detachSocket().then((socket) {
+ // We are testing that we can detach the socket, even though
+ // we made a new connection (testing it was not reused).
+ request.close().then((response) {
+ asyncStart();
+ response.listen(null, onDone: () {
+ server.close();
+ asyncEnd();
+ });
+ socket.add([0]);
+ socket.close();
+ socket.fold([], (l, d) => l..addAll(d))
+ .then((data) {
+ asyncEnd();
+ Expect.listEquals([0], data);
+ });
+ });
+ });
+ });
+ });
+ });
+}
+
void main() {
testServerDetachSocket();
testServerDetachSocketNoWriteHeaders();
testBadServerDetachSocket();
testClientDetachSocket();
+ testUpgradedConnection();
}
« 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