| 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:isolate"); | 6 #import("dart:isolate"); |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 | 8 |
| 9 void testNoBody(int totalConnections, bool explicitContentLength) { | 9 void testNoBody(int totalConnections, bool explicitContentLength) { |
| 10 HttpServer server = new HttpServer(); | 10 HttpServer server = new HttpServer(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 if (explicitContentLength) { | 30 if (explicitContentLength) { |
| 31 request.contentLength = 0; | 31 request.contentLength = 0; |
| 32 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); | 32 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); |
| 33 } | 33 } |
| 34 stream.close(); | 34 stream.close(); |
| 35 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); | 35 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); |
| 36 }; | 36 }; |
| 37 conn.onResponse = (HttpClientResponse response) { | 37 conn.onResponse = (HttpClientResponse response) { |
| 38 Expect.equals("0", response.headers.value('content-length')); | 38 Expect.equals("0", response.headers.value('content-length')); |
| 39 Expect.equals(0, response.contentLength); | 39 Expect.equals(0, response.contentLength); |
| 40 count++; | |
| 41 response.inputStream.onData = response.inputStream.read; | 40 response.inputStream.onData = response.inputStream.read; |
| 42 response.inputStream.onClosed = () { | 41 response.inputStream.onClosed = () { |
| 43 if (count == totalConnections) { | 42 if (++count == totalConnections) { |
| 44 client.shutdown(); | 43 client.shutdown(); |
| 45 server.close(); | 44 server.close(); |
| 46 } | 45 } |
| 47 }; | 46 }; |
| 48 }; | 47 }; |
| 49 } | 48 } |
| 50 } | 49 } |
| 51 | 50 |
| 52 void testBody(int totalConnections) { | 51 void testBody(int totalConnections) { |
| 53 HttpServer server = new HttpServer(); | 52 HttpServer server = new HttpServer(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 77 stream.writeString("x"); | 76 stream.writeString("x"); |
| 78 Expect.throws(() => request.contentLength = 3, (e) => e is HttpException); | 77 Expect.throws(() => request.contentLength = 3, (e) => e is HttpException); |
| 79 stream.writeString("x"); | 78 stream.writeString("x"); |
| 80 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); | 79 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); |
| 81 stream.close(); | 80 stream.close(); |
| 82 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); | 81 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException); |
| 83 }; | 82 }; |
| 84 conn.onResponse = (HttpClientResponse response) { | 83 conn.onResponse = (HttpClientResponse response) { |
| 85 Expect.equals("2", response.headers.value('content-length')); | 84 Expect.equals("2", response.headers.value('content-length')); |
| 86 Expect.equals(2, response.contentLength); | 85 Expect.equals(2, response.contentLength); |
| 87 count++; | |
| 88 response.inputStream.onData = response.inputStream.read; | 86 response.inputStream.onData = response.inputStream.read; |
| 89 response.inputStream.onClosed = () { | 87 response.inputStream.onClosed = () { |
| 90 if (count == totalConnections) { | 88 if (++count == totalConnections) { |
| 91 client.shutdown(); | 89 client.shutdown(); |
| 92 server.close(); | 90 server.close(); |
| 93 } | 91 } |
| 94 }; | 92 }; |
| 95 }; | 93 }; |
| 96 } | 94 } |
| 97 } | 95 } |
| 98 | 96 |
| 99 void testHttp10() { | 97 void testHttp10() { |
| 100 HttpServer server = new HttpServer(); | 98 HttpServer server = new HttpServer(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 121 }; | 119 }; |
| 122 }; | 120 }; |
| 123 } | 121 } |
| 124 | 122 |
| 125 void main() { | 123 void main() { |
| 126 testNoBody(5, false); | 124 testNoBody(5, false); |
| 127 testNoBody(5, true); | 125 testNoBody(5, true); |
| 128 testBody(5); | 126 testBody(5); |
| 129 testHttp10(); | 127 testHttp10(); |
| 130 } | 128 } |
| OLD | NEW |