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

Side by Side Diff: tests/standalone/io/http_parser_test.dart

Issue 15842004: Support auto-drain of HttpRequest data. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add documentation. Created 7 years, 6 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 | « sdk/lib/io/http_parser.dart ('k') | tests/standalone/io/http_server_response_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:math'; 7 import 'dart:math';
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 expectedHeaders.forEach( 67 expectedHeaders.forEach(
68 (String name, String value) => 68 (String name, String value) =>
69 Expect.equals(value, headers[name][0])); 69 Expect.equals(value, headers[name][0]));
70 } 70 }
71 incoming.listen( 71 incoming.listen(
72 (List<int> data) { 72 (List<int> data) {
73 Expect.isFalse(upgraded); 73 Expect.isFalse(upgraded);
74 bytesReceived += data.length; 74 bytesReceived += data.length;
75 }, 75 },
76 onDone: () { 76 onDone: () {
77 Expect.isFalse(upgraded);
78 port2.close(); 77 port2.close();
79 Expect.equals(expectedMethod, method); 78 Expect.equals(expectedMethod, method);
80 Expect.stringEquals(expectedUri, uri.toString()); 79 Expect.stringEquals(expectedUri, uri.toString());
81 Expect.equals(expectedVersion, headers.protocolVersion); 80 Expect.equals(expectedVersion, headers.protocolVersion);
82 if (upgrade) { 81 if (upgrade) {
83 Expect.equals(0, bytesReceived); 82 Expect.equals(0, bytesReceived);
84 // port1 is closed by the listener on the detached data. 83 // port1 is closed by the listener on the detached data.
85 } else { 84 } else {
86 Expect.equals(expectedBytesReceived, bytesReceived); 85 Expect.equals(expectedBytesReceived, bytesReceived);
87 } 86 }
88 }); 87 });
89 88
90 if (upgraded) { 89 if (upgraded) {
91 port1.close(); 90 port1.close();
92 httpParser.detachIncoming().listen( 91 httpParser.detachIncoming().listen(
93 (List<int> data) { 92 (List<int> data) {
94 unparsedBytesReceived += data.length; 93 unparsedBytesReceived += data.length;
95 }, 94 },
96 onDone: () { 95 onDone: () {
97 Expect.equals(unparsedLength, unparsedBytesReceived); 96 Expect.equals(unparsedLength, unparsedBytesReceived);
98 port2.close(); 97 port2.close();
99 }); 98 });
100 } 99 }
101 100
102 incoming.dataDone.then((_) { 101 incoming.dataDone.then((_) {
103 port1.close(); 102 port1.close();
104 Expect.isFalse(upgraded);
105 }); 103 });
106 }); 104 });
107 105
108 method = null; 106 method = null;
109 uri = null; 107 uri = null;
110 headers = null; 108 headers = null;
111 bytesReceived = 0; 109 bytesReceived = 0;
112 unparsedBytesReceived = 0; 110 unparsedBytesReceived = 0;
113 upgraded = false; 111 upgraded = false;
114 } 112 }
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 0123456789012345678901234567890\r 865 0123456789012345678901234567890\r
868 0\r\n\r\n"""; 866 0\r\n\r\n""";
869 _testParseInvalidResponse(response); 867 _testParseInvalidResponse(response);
870 } 868 }
871 } 869 }
872 870
873 871
874 void main() { 872 void main() {
875 HttpParserTest.runAllTests(); 873 HttpParserTest.runAllTests();
876 } 874 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | tests/standalone/io/http_server_response_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698