| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 HttpClient httpClient = new HttpClient(); | 166 HttpClient httpClient = new HttpClient(); |
| 167 void sendRequest() { | 167 void sendRequest() { |
| 168 HttpClientConnection conn = | 168 HttpClientConnection conn = |
| 169 httpClient.post("127.0.0.1", port, "/echo"); | 169 httpClient.post("127.0.0.1", port, "/echo"); |
| 170 conn.onRequest = (HttpClientRequest request) { | 170 conn.onRequest = (HttpClientRequest request) { |
| 171 if (chunkedEncoding) { | 171 if (chunkedEncoding) { |
| 172 request.outputStream.writeString(data.substring(0, 10)); | 172 request.outputStream.writeString(data.substring(0, 10)); |
| 173 request.outputStream.writeString(data.substring(10, data.length)); | 173 request.outputStream.writeString(data.substring(10, data.length)); |
| 174 } else { | 174 } else { |
| 175 request.contentLength = data.length; | 175 request.contentLength = data.length; |
| 176 request.outputStream.write(data.charCodes()); | 176 request.outputStream.write(data.charCodes); |
| 177 } | 177 } |
| 178 request.outputStream.close(); | 178 request.outputStream.close(); |
| 179 }; | 179 }; |
| 180 conn.onResponse = (HttpClientResponse response) { | 180 conn.onResponse = (HttpClientResponse response) { |
| 181 Expect.equals(HttpStatus.OK, response.statusCode); | 181 Expect.equals(HttpStatus.OK, response.statusCode); |
| 182 InputStream stream = response.inputStream; | 182 InputStream stream = response.inputStream; |
| 183 List<int> body = new List<int>(); | 183 List<int> body = new List<int>(); |
| 184 stream.onData = () { | 184 stream.onData = () { |
| 185 List tmp = new List(3); | 185 List tmp = new List(3); |
| 186 int bytes = stream.readInto(tmp); | 186 int bytes = stream.readInto(tmp); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 HttpClient httpClient = new HttpClient(); | 220 HttpClient httpClient = new HttpClient(); |
| 221 void sendRequest() { | 221 void sendRequest() { |
| 222 HttpClientConnection conn = | 222 HttpClientConnection conn = |
| 223 httpClient.post("127.0.0.1", port, "/echo"); | 223 httpClient.post("127.0.0.1", port, "/echo"); |
| 224 conn.onRequest = (HttpClientRequest request) { | 224 conn.onRequest = (HttpClientRequest request) { |
| 225 if (chunkedEncoding) { | 225 if (chunkedEncoding) { |
| 226 request.outputStream.writeString(data.substring(0, 10)); | 226 request.outputStream.writeString(data.substring(0, 10)); |
| 227 request.outputStream.writeString(data.substring(10, data.length)); | 227 request.outputStream.writeString(data.substring(10, data.length)); |
| 228 } else { | 228 } else { |
| 229 request.contentLength = data.length; | 229 request.contentLength = data.length; |
| 230 request.outputStream.write(data.charCodes()); | 230 request.outputStream.write(data.charCodes); |
| 231 } | 231 } |
| 232 request.outputStream.close(); | 232 request.outputStream.close(); |
| 233 }; | 233 }; |
| 234 conn.onResponse = (HttpClientResponse response) { | 234 conn.onResponse = (HttpClientResponse response) { |
| 235 Expect.equals(HttpStatus.OK, response.statusCode); | 235 Expect.equals(HttpStatus.OK, response.statusCode); |
| 236 InputStream stream = response.inputStream; | 236 InputStream stream = response.inputStream; |
| 237 List<int> body = new List<int>(); | 237 List<int> body = new List<int>(); |
| 238 stream.onData = () { | 238 stream.onData = () { |
| 239 List tmp = stream.read(2); | 239 List tmp = stream.read(2); |
| 240 body.addAll(tmp); | 240 body.addAll(tmp); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 261 } | 261 } |
| 262 testServerMain.start(); | 262 testServerMain.start(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void main() { | 265 void main() { |
| 266 testReadInto(true); | 266 testReadInto(true); |
| 267 testReadInto(false); | 267 testReadInto(false); |
| 268 testReadShort(true); | 268 testReadShort(true); |
| 269 testReadShort(false); | 269 testReadShort(false); |
| 270 } | 270 } |
| OLD | NEW |