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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library utils;
6
7 import 'dart:async';
8 import 'dart:io';
9
10
11 Future<int> getStatusCode(int port,
12 String path,
13 {String host,
14 bool secure: false,
15 DateTime ifModifiedSince}) {
16 var uri = (secure ?
17 new Uri.https('localhost:$port', path) :
18 new Uri.http('localhost:$port', path));
19 return new HttpClient().getUrl(uri)
20 .then((request) {
21 if (host != null) request.headers.host = host;
22 if (ifModifiedSince != null) {
23 request.headers.ifModifiedSince = ifModifiedSince;
24 }
25 return request.close();
26 })
27 .then((response) => response.drain().then(
28 (_) => response.statusCode));
29 }
30
31
32 Future<HttpHeaders> getHeaders(int port, String path) {
33 return new HttpClient().get('localhost', port, path)
34 .then((request) => request.close())
35 .then((response) => response.drain().then(
36 (_) => response.headers));
37 }
38
39
40 const CERTIFICATE = "localhost_cert";
41
42
43 setupSecure() {
44 Path scriptDir = new Path(new Options().script).directoryPath;
45 Path certificateDatabase = scriptDir.append('pkcert');
46 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
47 password: 'dartdart');
48 }
OLDNEW
« 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