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

Unified Diff: pkg/http_server/test/utils.dart

Issue 17581002: Add new VirtualHost class to http_server package, for handling multiple hosts on multiple sources (… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add cert and factor out getStatusCode and getHeaders to utils.dart. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http_server/test/pkcert/key4.db ('k') | pkg/http_server/test/virtual_directory_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http_server/test/utils.dart
diff --git a/pkg/http_server/test/utils.dart b/pkg/http_server/test/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7a28d8864ed7cba065f69a794123651c21ea58c1
--- /dev/null
+++ b/pkg/http_server/test/utils.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library utils;
+
+import 'dart:async';
+import 'dart:io';
+
+
+Future<int> getStatusCode(int port,
+ String path,
+ {String host,
+ bool secure: false,
+ DateTime ifModifiedSince}) {
+ var uri = (secure ?
+ new Uri.https('localhost:$port', path) :
+ new Uri.http('localhost:$port', path));
+ return new HttpClient().getUrl(uri)
+ .then((request) {
+ if (host != null) request.headers.host = host;
+ if (ifModifiedSince != null) {
+ request.headers.ifModifiedSince = ifModifiedSince;
+ }
+ return request.close();
+ })
+ .then((response) => response.drain().then(
+ (_) => response.statusCode));
+}
+
+
+Future<HttpHeaders> getHeaders(int port, String path) {
+ return new HttpClient().get('localhost', port, path)
+ .then((request) => request.close())
+ .then((response) => response.drain().then(
+ (_) => response.headers));
+}
+
+
+const CERTIFICATE = "localhost_cert";
+
+
+setupSecure() {
+ Path scriptDir = new Path(new Options().script).directoryPath;
+ Path certificateDatabase = scriptDir.append('pkcert');
+ SecureSocket.initialize(database: certificateDatabase.toNativePath(),
+ password: 'dartdart');
+}
« no previous file with comments | « pkg/http_server/test/pkcert/key4.db ('k') | pkg/http_server/test/virtual_directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698