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

Side by Side Diff: tests/standalone/src/io/HttpContentLengthTest.dart

Issue 10252020: test rename overhaul: step 12 - standalone (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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/src/io/HttpClientTest.dart ('k') | tests/standalone/src/io/HttpDateTest.dart » ('j') | 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4 //
5
6 #import("dart:isolate");
7 #import("dart:io");
8
9 void testNoBody(int totalConnections) {
10 HttpServer server = new HttpServer();
11 server.onError = (e) => Expect.fail("Unexpected error $e");
12 server.listen("127.0.0.1", 0, totalConnections);
13 server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
14 response.contentLength = 0;
15 OutputStream stream = response.outputStream;
16 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
17 stream.close();
18 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
19 };
20
21 int count = 0;
22 HttpClient client = new HttpClient();
23 for (int i = 0; i < totalConnections; i++) {
24 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
25 conn.onError = (e) => Expect.fail("Unexpected error $e");
26 conn.onRequest = (HttpClientRequest request) {
27 OutputStream stream = request.outputStream;
28 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
29 stream.close();
30 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
31 };
32 conn.onResponse = (HttpClientResponse response) {
33 count++;
34 if (count == totalConnections) {
35 client.shutdown();
36 server.close();
37 }
38 };
39 }
40 }
41
42 void testBody(int totalConnections) {
43 HttpServer server = new HttpServer();
44 server.onError = (e) => Expect.fail("Unexpected error $e");
45 server.listen("127.0.0.1", 0, totalConnections);
46 server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
47 response.contentLength = 2;
48 OutputStream stream = response.outputStream;
49 stream.writeString("x");
50 Expect.throws(() => response.contentLength = 3, (e) => e is HttpException);
51 stream.writeString("x");
52 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
53 stream.close();
54 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
55 };
56
57 int count = 0;
58 HttpClient client = new HttpClient();
59 for (int i = 0; i < totalConnections; i++) {
60 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
61 conn.onError = (e) => Expect.fail("Unexpected error $e");
62 conn.onRequest = (HttpClientRequest request) {
63 request.contentLength = 2;
64 OutputStream stream = request.outputStream;
65 stream.writeString("x");
66 Expect.throws(() => request.contentLength = 3, (e) => e is HttpException);
67 stream.writeString("x");
68 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
69 stream.close();
70 Expect.throws(() => stream.writeString("x"), (e) => e is HttpException);
71 };
72 conn.onResponse = (HttpClientResponse response) {
73 count++;
74 if (count == totalConnections) {
75 client.shutdown();
76 server.close();
77 }
78 };
79 }
80 }
81
82 void main() {
83 testNoBody(5);
84 testBody(5);
85 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/HttpClientTest.dart ('k') | tests/standalone/src/io/HttpDateTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698