| OLD | NEW |
| (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 } |
| OLD | NEW |