Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "dart:async"; | 5 import "dart:async"; |
| 6 import "dart:typed_data"; | 6 import "dart:typed_data"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 | 8 |
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| 11 | 11 |
| 12 void testDefaultResponseHeaders() { | |
|
Anders Johnsen
2014/08/08 06:15:45
Also test actual changing the headers, including e
Søren Gjesse
2014/08/11 14:10:09
Done.
| |
| 13 HttpServer.bind("127.0.0.1", 0).then((server) { | |
| 14 Expect.listEquals(server.defaultResponseHeaders[HttpHeaders.CONTENT_TYPE], | |
| 15 ['text/plain; charset=utf-8']); | |
| 16 Expect.listEquals(server.defaultResponseHeaders['X-Frame-Options'], | |
| 17 ['SAMEORIGIN']); | |
| 18 Expect.listEquals(server.defaultResponseHeaders['X-Content-Type-Options'], | |
| 19 ['nosniff']); | |
| 20 Expect.listEquals(server.defaultResponseHeaders['X-XSS-Protection'], | |
| 21 ['1; mode=block']); | |
| 22 server.close(); | |
| 23 }); | |
| 24 } | |
| 25 | |
| 12 void testListenOn() { | 26 void testListenOn() { |
| 13 ServerSocket socket; | 27 ServerSocket socket; |
| 14 HttpServer server; | 28 HttpServer server; |
| 15 | 29 |
| 16 void test(void onDone()) { | 30 void test(void onDone()) { |
| 17 Expect.equals(socket.port, server.port); | 31 Expect.equals(socket.port, server.port); |
| 18 | 32 |
| 19 HttpClient client = new HttpClient(); | 33 HttpClient client = new HttpClient(); |
| 20 client.get("127.0.0.1", socket.port, "/") | 34 client.get("127.0.0.1", socket.port, "/") |
| 21 .then((request) { | 35 .then((request) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 client.get("127.0.0.1", server.port, "/") | 144 client.get("127.0.0.1", server.port, "/") |
| 131 .then((request) => request.close()) | 145 .then((request) => request.close()) |
| 132 .then((response) { | 146 .then((response) { |
| 133 response.listen((_) {}).cancel(); | 147 response.listen((_) {}).cancel(); |
| 134 }); | 148 }); |
| 135 }); | 149 }); |
| 136 } | 150 } |
| 137 | 151 |
| 138 | 152 |
| 139 void main() { | 153 void main() { |
| 154 testDefaultResponseHeaders(); | |
| 140 testListenOn(); | 155 testListenOn(); |
| 141 testHttpServerZone(); | 156 testHttpServerZone(); |
| 142 testHttpServerZoneError(); | 157 testHttpServerZoneError(); |
| 143 testHttpServerClientClose(); | 158 testHttpServerClientClose(); |
| 144 } | 159 } |
| OLD | NEW |