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

Side by Side Diff: pkg/http_multi_server/test/http_multi_server_test.dart

Issue 469583002: Add support for HttpServer.defaultResponseHeaders to HttpMultiServer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | « pkg/http_multi_server/pubspec.yaml ('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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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 library http_multi_server.test; 5 library http_multi_server.test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:http/http.dart' as http; 10 import 'package:http/http.dart' as http;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 expect(_get(subServer2).then((response) { 54 expect(_get(subServer2).then((response) {
55 expect(response.headers['server'], equals("http_multi_server test")); 55 expect(response.headers['server'], equals("http_multi_server test"));
56 }), completes); 56 }), completes);
57 57
58 expect(_get(subServer3).then((response) { 58 expect(_get(subServer3).then((response) {
59 expect(response.headers['server'], equals("http_multi_server test")); 59 expect(response.headers['server'], equals("http_multi_server test"));
60 }), completes); 60 }), completes);
61 }); 61 });
62 62
63 test("headers.set sets the value for all servers", () {
64 multiServer.defaultResponseHeaders.set(
65 "server", "http_multi_server test");
66
67 multiServer.listen((request) {
68 request.response.write("got request");
69 request.response.close();
70 });
71
72 expect(_get(subServer1).then((response) {
73 expect(response.headers['server'], equals("http_multi_server test"));
74 }), completes);
75
76 expect(_get(subServer2).then((response) {
77 expect(response.headers['server'], equals("http_multi_server test"));
78 }), completes);
79
80 expect(_get(subServer3).then((response) {
81 expect(response.headers['server'], equals("http_multi_server test"));
82 }), completes);
83 });
84
63 test("connectionsInfo sums the values for all servers", () { 85 test("connectionsInfo sums the values for all servers", () {
64 var pendingRequests = 0; 86 var pendingRequests = 0;
65 var awaitingResponseCompleter = new Completer(); 87 var awaitingResponseCompleter = new Completer();
66 var sendResponseCompleter = new Completer(); 88 var sendResponseCompleter = new Completer();
67 multiServer.listen((request) { 89 multiServer.listen((request) {
68 sendResponseCompleter.future.then((_) { 90 sendResponseCompleter.future.then((_) {
69 request.response.write("got request"); 91 request.response.write("got request");
70 request.response.close(); 92 request.response.close();
71 }); 93 });
72 94
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 141
120 /// Makes a GET request to the root of [server] and returns the response. 142 /// Makes a GET request to the root of [server] and returns the response.
121 Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server)); 143 Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server));
122 144
123 /// Makes a GET request to the root of [server] and returns the response body. 145 /// Makes a GET request to the root of [server] and returns the response body.
124 Future<String> _read(HttpServer server) => http.read(_urlFor(server)); 146 Future<String> _read(HttpServer server) => http.read(_urlFor(server));
125 147
126 /// Returns the URL for the root of [server]. 148 /// Returns the URL for the root of [server].
127 String _urlFor(HttpServer server) => 149 String _urlFor(HttpServer server) =>
128 "http://${server.address.host}:${server.port}/"; 150 "http://${server.address.host}:${server.port}/";
OLDNEW
« no previous file with comments | « pkg/http_multi_server/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698