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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:io';
6 import 'dart:typed_data';
7
8 import 'package:expect/expect.dart';
9
10 void testChunkedBufferSizeMsg() {
11 // Buffer of same size as our internal buffer, minus 4. Makes us hit the
12 // boundary.
13 var sendData = new Uint8List(8 * 1024 - 4);
14 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
15
16 HttpServer.bind('127.0.0.1', 0).then((server) {
17 server.listen((request) {
18 // Chunked is on by default. Be sure no data is lost when sending several
19 // chunks of data.
20 request.response.add(sendData);
21 request.response.add(sendData);
22 request.response.add(sendData);
23 request.response.add(sendData);
24 request.response.add(sendData);
25 request.response.add(sendData);
26 request.response.add(sendData);
27 request.response.add(sendData);
28 request.response.close();
29 });
30 var client = new HttpClient();
31 client.get('127.0.0.1', server.port, '/')
32 .then((request) {
33 request.headers.set(HttpHeaders.ACCEPT_ENCODING, "");
34 return request.close();
35 })
36 .then((response) {
37 var buffer = [];
38 response.listen(
39 (data) => buffer.addAll(data),
40 onDone: () {
41 Expect.equals(sendData.length * 8, buffer.length);
42 for (int i = 0; i < buffer.length; i++) {
43 Expect.equals(sendData[i % sendData.length], buffer[i]);
44 }
45 server.close();
46 });
47 });
48 });
49 }
50
51
52 void main() {
53 testChunkedBufferSizeMsg();
54 }
OLDNEW
« 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