Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 Expect.equals(1, errors); | 144 Expect.equals(1, errors); |
| 145 asyncEnd(); | 145 asyncEnd(); |
| 146 }); | 146 }); |
| 147 }); | 147 }); |
| 148 }); | 148 }); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void testPostEmptyRequest() { | 151 void testPostEmptyRequest() { |
| 152 HttpServer.bind("127.0.0.1", 0).then((server) { | 152 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 153 server.listen((request) { | 153 server.listen((request) { |
| 154 Expect.equals('POST', request.method); | |
| 154 request.pipe(request.response); | 155 request.pipe(request.response); |
| 155 }); | 156 }); |
| 156 | 157 |
| 157 var client = new HttpClient(); | 158 var client = new HttpClient(); |
| 158 client.post("127.0.0.1", server.port, "/") | 159 client.post("127.0.0.1", server.port, "/") |
| 159 .then((request) => request.close()) | 160 .then((request) => request.close()) |
| 160 .then((response) { | 161 .then((response) { |
| 161 response.listen((data) {}, onDone: server.close); | 162 response.listen((data) {}, onDone: server.close); |
| 162 }); | 163 }); |
| 163 }); | 164 }); |
| 164 } | 165 } |
| 165 | 166 |
| 166 | 167 |
| 168 void testPutEmptyRequest() { | |
| 169 HttpServer.bind("127.0.0.1", 0).then((server) { | |
| 170 server.listen((request) { | |
| 171 Expect.equals('PUT', request.method); | |
| 172 request.pipe(request.response); | |
| 173 }); | |
| 174 | |
| 175 var client = new HttpClient(); | |
| 176 client.put("127.0.0.1", server.port, "/") | |
| 177 .then((request) => request.close()) | |
| 178 .then((response) { | |
| 179 response.listen((data) {}, onDone: server.close); | |
| 180 }); | |
| 181 }); | |
| 182 } | |
| 183 | |
| 184 | |
| 185 void testDeleteEmptyRequest() { | |
| 186 HttpServer.bind("127.0.0.1", 0).then((server) { | |
| 187 server.listen((request) { | |
| 188 Expect.equals('DELETE', request.method); | |
| 189 request.pipe(request.response); | |
| 190 }); | |
| 191 | |
| 192 var client = new HttpClient(); | |
| 193 client.delete("127.0.0.1", server.port, "/") | |
| 194 .then((request) => request.close()) | |
| 195 .then((response) { | |
| 196 response.listen((data) {}, onDone: server.close); | |
| 197 }); | |
| 198 }); | |
| 199 } | |
|
Lasse Reichstein Nielsen
2014/04/22 08:49:47
Test putUrl and deleteUrl?
Anders Johnsen
2014/04/22 10:58:36
Done.
| |
| 200 | |
| 201 | |
| 167 void testNoBuffer() { | 202 void testNoBuffer() { |
| 168 asyncStart(); | 203 asyncStart(); |
| 169 HttpServer.bind("127.0.0.1", 0).then((server) { | 204 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 170 var response; | 205 var response; |
| 171 server.listen((request) { | 206 server.listen((request) { |
| 172 response = request.response; | 207 response = request.response; |
| 173 response.bufferOutput = false; | 208 response.bufferOutput = false; |
| 174 response.writeln('init'); | 209 response.writeln('init'); |
| 175 }); | 210 }); |
| 176 | 211 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 | 247 |
| 213 void main() { | 248 void main() { |
| 214 testGetEmptyRequest(); | 249 testGetEmptyRequest(); |
| 215 testGetDataRequest(); | 250 testGetDataRequest(); |
| 216 testGetInvalidHost(); | 251 testGetInvalidHost(); |
| 217 testGetServerClose(); | 252 testGetServerClose(); |
| 218 testGetServerCloseNoKeepAlive(); | 253 testGetServerCloseNoKeepAlive(); |
| 219 testGetServerForceClose(); | 254 testGetServerForceClose(); |
| 220 testGetDataServerForceClose(); | 255 testGetDataServerForceClose(); |
| 221 testPostEmptyRequest(); | 256 testPostEmptyRequest(); |
| 257 testPutEmptyRequest(); | |
| 258 testDeleteEmptyRequest(); | |
| 222 testNoBuffer(); | 259 testNoBuffer(); |
| 223 } | 260 } |
| OLD | NEW |