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

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: Cleanup 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
« no previous file with comments | « tests/standalone/io/http_content_length_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // VMOptions=
6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write
9
10 import 'dart:io';
11 import 'dart:typed_data';
12
13 import 'package:expect/expect.dart';
14
15 void testChunkedBufferSizeMsg() {
16 // Buffer of same size as our internal buffer, minus 4. Makes us hit the
17 // boundary.
18 var sendData = new Uint8List(8 * 1024 - 4);
19 for (int i = 0; i < sendData.length; i++) sendData[i] = i % 256;
20
21 HttpServer.bind('127.0.0.1', 0).then((server) {
22 server.listen((request) {
23 // Chunked is on by default. Be sure no data is lost when sending several
24 // chunks of data.
25 request.response.add(sendData);
26 request.response.add(sendData);
27 request.response.add(sendData);
28 request.response.add(sendData);
29 request.response.add(sendData);
30 request.response.add(sendData);
31 request.response.add(sendData);
32 request.response.add(sendData);
33 request.response.close();
34 });
35 var client = new HttpClient();
36 client.get('127.0.0.1', server.port, '/')
37 .then((request) {
38 request.headers.set(HttpHeaders.ACCEPT_ENCODING, "");
39 return request.close();
40 })
41 .then((response) {
42 var buffer = [];
43 response.listen(
44 (data) => buffer.addAll(data),
45 onDone: () {
46 Expect.equals(sendData.length * 8, buffer.length);
47 for (int i = 0; i < buffer.length; i++) {
48 Expect.equals(sendData[i % sendData.length], buffer[i]);
49 }
50 server.close();
51 });
52 });
53 });
54 }
55
56
57 void main() {
58 testChunkedBufferSizeMsg();
59 }
OLDNEW
« no previous file with comments | « 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