Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1534)

Unified Diff: tests/standalone/io/http_outgoing_size_test.dart

Issue 185543004: Merge all http-outgoing transfomers into _HttpOutgoing, including simpler(better) buffering. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/http_outgoing_size_test.dart
diff --git a/tests/standalone/io/http_outgoing_size_test.dart b/tests/standalone/io/http_outgoing_size_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9b4c63fa8611b5ad30c3d7220a3ec87587342389
--- /dev/null
+++ b/tests/standalone/io/http_outgoing_size_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+import 'dart:typed_data';
+
+import 'package:expect/expect.dart';
+
+void testChunkedBufferSizeMsg() {
+ // Buffer of same size as our internal buffer, minus 4. Makes us hit the
+ // boundary.
+ var sendData = new Uint8List(8 * 1024 - 4);
+ for (int i = 0; i < sendData.length; i++) sendData[i] = i;
Søren Gjesse 2014/03/04 09:29:15 Change i to i % 255 for clarity.
Anders Johnsen 2014/03/04 13:54:16 Done, with % 256
+
+ HttpServer.bind('127.0.0.1', 0).then((server) {
+ server.listen((request) {
+ // Chunked is on by default. Be sure no data is lost when sending several
+ // chunks of data.
+ request.response.add(sendData);
+ request.response.add(sendData);
+ request.response.add(sendData);
+ request.response.add(sendData);
+ request.response.add(sendData);
+ request.response.add(sendData);
+ request.response.add(sendData);
+ request.response.add(sendData);
+ request.response.close();
+ });
+ var client = new HttpClient();
+ client.get('127.0.0.1', server.port, '/')
+ .then((request) {
+ request.headers.set(HttpHeaders.ACCEPT_ENCODING, "");
+ return request.close();
+ })
+ .then((response) {
+ var buffer = [];
+ response.listen(
+ (data) => buffer.addAll(data),
+ onDone: () {
+ Expect.equals(sendData.length * 8, buffer.length);
+ for (int i = 0; i < buffer.length; i++) {
+ Expect.equals(sendData[i % sendData.length], buffer[i]);
+ }
+ server.close();
+ });
+ });
+ });
+}
+
+
+void main() {
+ testChunkedBufferSizeMsg();
+}
« sdk/lib/io/http_impl.dart ('K') | « tests/standalone/io/http_content_length_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698