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

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

Issue 598453003: Add HttpServer:autoCompress option, to disable auto gzip compression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test. Created 6 years, 2 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
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 expect(response.headers['server'], equals("http_multi_server test")); 51 expect(response.headers['server'], equals("http_multi_server test"));
52 }), completes); 52 }), completes);
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 }
62 );
nweiz 2014/09/23 19:34:46 Nit: "});"
Anders Johnsen 2014/09/24 09:33:13 Done.
63 test("autoCompress= sets the value for all servers", () {
nweiz 2014/09/23 19:34:46 Nit: empty line between tests.
Anders Johnsen 2014/09/24 09:33:13 Done.
64 multiServer.autoCompress = true;
65
66 multiServer.listen((request) {
67 request.response.write("got request");
68 request.response.close();
69 });
70
71 expect(_get(subServer1).then((response) {
72 expect(response.headers['content-encoding'], equals("gzip"));
73 }), completes);
74
75 expect(_get(subServer2).then((response) {
76 expect(response.headers['content-encoding'], equals("gzip"));
77 }), completes);
78
79 expect(_get(subServer3).then((response) {
80 expect(response.headers['content-encoding'], equals("gzip"));
81 }), completes);
61 }); 82 });
62 83
63 test("headers.set sets the value for all servers", () { 84 test("headers.set sets the value for all servers", () {
64 multiServer.defaultResponseHeaders.set( 85 multiServer.defaultResponseHeaders.set(
65 "server", "http_multi_server test"); 86 "server", "http_multi_server test");
66 87
67 multiServer.listen((request) { 88 multiServer.listen((request) {
68 request.response.write("got request"); 89 request.response.write("got request");
69 request.response.close(); 90 request.response.close();
70 }); 91 });
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 162
142 /// Makes a GET request to the root of [server] and returns the response. 163 /// Makes a GET request to the root of [server] and returns the response.
143 Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server)); 164 Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server));
144 165
145 /// Makes a GET request to the root of [server] and returns the response body. 166 /// Makes a GET request to the root of [server] and returns the response body.
146 Future<String> _read(HttpServer server) => http.read(_urlFor(server)); 167 Future<String> _read(HttpServer server) => http.read(_urlFor(server));
147 168
148 /// Returns the URL for the root of [server]. 169 /// Returns the URL for the root of [server].
149 String _urlFor(HttpServer server) => 170 String _urlFor(HttpServer server) =>
150 "http://${server.address.host}:${server.port}/"; 171 "http://${server.address.host}:${server.port}/";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698