| OLD | NEW |
| 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:io"); | 6 #import("dart:io"); |
| 7 | 7 |
| 8 void testRequestResponseClientCloses( | 8 void testRequestResponseClientCloses( |
| 9 int totalConnections, int closeStatus, String closeReason) { | 9 int totalConnections, int closeStatus, String closeReason) { |
| 10 HttpServer server = new HttpServer(); | 10 HttpServer server = new HttpServer(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 server.listen("127.0.0.1", 0, 5); | 108 server.listen("127.0.0.1", 0, 5); |
| 109 | 109 |
| 110 // Create a server which always responds with a redirect. | 110 // Create a server which always responds with a redirect. |
| 111 server.defaultRequestHandler = (request, response) { | 111 server.defaultRequestHandler = (request, response) { |
| 112 response.statusCode = HttpStatus.MOVED_PERMANENTLY; | 112 response.statusCode = HttpStatus.MOVED_PERMANENTLY; |
| 113 response.outputStream.close(); | 113 response.outputStream.close(); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); | 116 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); |
| 117 conn.followRedirects = false; |
| 117 WebSocketClientConnection wsconn = new WebSocketClientConnection(conn); | 118 WebSocketClientConnection wsconn = new WebSocketClientConnection(conn); |
| 118 wsconn.onNoUpgrade = (response) { | 119 wsconn.onNoUpgrade = (response) { |
| 119 Expect.equals(HttpStatus.MOVED_PERMANENTLY, response.statusCode); | 120 Expect.equals(HttpStatus.MOVED_PERMANENTLY, response.statusCode); |
| 120 client.shutdown(); | 121 client.shutdown(); |
| 121 server.close(); | 122 server.close(); |
| 122 }; | 123 }; |
| 123 } | 124 } |
| 124 | 125 |
| 125 void testUsePOST() { | 126 void testUsePOST() { |
| 126 HttpServer server = new HttpServer(); | 127 HttpServer server = new HttpServer(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 149 main() { | 150 main() { |
| 150 testRequestResponseClientCloses(2, null, null); | 151 testRequestResponseClientCloses(2, null, null); |
| 151 testRequestResponseClientCloses(2, 3001, null); | 152 testRequestResponseClientCloses(2, 3001, null); |
| 152 testRequestResponseClientCloses(2, 3002, "Got tired"); | 153 testRequestResponseClientCloses(2, 3002, "Got tired"); |
| 153 testRequestResponseServerCloses(2, null, null); | 154 testRequestResponseServerCloses(2, null, null); |
| 154 testRequestResponseServerCloses(2, 3001, null); | 155 testRequestResponseServerCloses(2, 3001, null); |
| 155 testRequestResponseServerCloses(2, 3002, "Got tired"); | 156 testRequestResponseServerCloses(2, 3002, "Got tired"); |
| 156 testNoUpgrade(); | 157 testNoUpgrade(); |
| 157 testUsePOST(); | 158 testUsePOST(); |
| 158 } | 159 } |
| OLD | NEW |