| OLD | NEW |
| 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 Loading... |
| 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 } | 61 }); |
| 62 ); | 62 |
| 63 test("autoCompress= sets the value for all servers", () { | 63 test("autoCompress= sets the value for all servers", () { |
| 64 multiServer.autoCompress = true; | 64 multiServer.autoCompress = true; |
| 65 | 65 |
| 66 multiServer.listen((request) { | 66 multiServer.listen((request) { |
| 67 request.response.write("got request"); | 67 request.response.write("got request"); |
| 68 request.response.close(); | 68 request.response.close(); |
| 69 }); | 69 }); |
| 70 | 70 |
| 71 expect(_get(subServer1).then((response) { | 71 expect(_get(subServer1).then((response) { |
| 72 expect(response.headers['content-encoding'], equals("gzip")); | 72 expect(response.headers['content-encoding'], equals("gzip")); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 /// 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. |
| 164 Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server)); | 164 Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server)); |
| 165 | 165 |
| 166 /// 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. |
| 167 Future<String> _read(HttpServer server) => http.read(_urlFor(server)); | 167 Future<String> _read(HttpServer server) => http.read(_urlFor(server)); |
| 168 | 168 |
| 169 /// Returns the URL for the root of [server]. | 169 /// Returns the URL for the root of [server]. |
| 170 String _urlFor(HttpServer server) => | 170 String _urlFor(HttpServer server) => |
| 171 "http://${server.address.host}:${server.port}/"; | 171 "http://${server.address.host}:${server.port}/"; |
| OLD | NEW |