| 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 // 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:isolate"; | 10 import "dart:isolate"; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 HttpClient httpClient = new HttpClient(); | 221 HttpClient httpClient = new HttpClient(); |
| 222 void sendRequest() { | 222 void sendRequest() { |
| 223 HttpClientConnection conn = | 223 HttpClientConnection conn = |
| 224 httpClient.post("127.0.0.1", port, "/echo"); | 224 httpClient.post("127.0.0.1", port, "/echo"); |
| 225 conn.onRequest = (HttpClientRequest request) { | 225 conn.onRequest = (HttpClientRequest request) { |
| 226 if (chunkedEncoding) { | 226 if (chunkedEncoding) { |
| 227 request.outputStream.writeString(data.substring(0, 10)); | 227 request.outputStream.writeString(data.substring(0, 10)); |
| 228 request.outputStream.writeString(data.substring(10, data.length)); | 228 request.outputStream.writeString(data.substring(10, data.length)); |
| 229 } else { | 229 } else { |
| 230 request.contentLength = data.length; | 230 request.contentLength = data.length; |
| 231 request.outputStream.write(data.charCodes); | 231 request.outputStream.write(data.codeUnits); |
| 232 } | 232 } |
| 233 request.outputStream.close(); | 233 request.outputStream.close(); |
| 234 }; | 234 }; |
| 235 conn.onResponse = (HttpClientResponse response) { | 235 conn.onResponse = (HttpClientResponse response) { |
| 236 Expect.equals(HttpStatus.OK, response.statusCode); | 236 Expect.equals(HttpStatus.OK, response.statusCode); |
| 237 StringInputStream stream = new StringInputStream(response.inputStream); | 237 StringInputStream stream = new StringInputStream(response.inputStream); |
| 238 StringBuffer body = new StringBuffer(); | 238 StringBuffer body = new StringBuffer(); |
| 239 stream.onData = () => body.add(stream.read()); | 239 stream.onData = () => body.add(stream.read()); |
| 240 stream.onClosed = () { | 240 stream.onClosed = () { |
| 241 Expect.equals(data, body.toString()); | 241 Expect.equals(data, body.toString()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 303 } |
| 304 | 304 |
| 305 void main() { | 305 void main() { |
| 306 testStartStop(); | 306 testStartStop(); |
| 307 testGET(); | 307 testGET(); |
| 308 testPOST(true); | 308 testPOST(true); |
| 309 testPOST(false); | 309 testPOST(false); |
| 310 test404(); | 310 test404(); |
| 311 testReasonPhrase(); | 311 testReasonPhrase(); |
| 312 } | 312 } |
| OLD | NEW |