| 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 library utils; | 5 library utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; |
| 8 import 'dart:io'; | 9 import 'dart:io'; |
| 9 import "package:path/path.dart"; | 10 import "package:path/path.dart"; |
| 10 | 11 |
| 11 Future<int> getStatusCode(int port, | 12 Future<int> getStatusCode(int port, |
| 12 String path, | 13 String path, |
| 13 {String host, | 14 {String host, |
| 14 bool secure: false, | 15 bool secure: false, |
| 15 DateTime ifModifiedSince, | 16 DateTime ifModifiedSince, |
| 16 bool rawPath: false}) { | 17 bool rawPath: false}) { |
| 17 var uri; | 18 var uri; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 42 return new HttpClient().get('localhost', port, path) | 43 return new HttpClient().get('localhost', port, path) |
| 43 .then((request) => request.close()) | 44 .then((request) => request.close()) |
| 44 .then((response) => response.drain().then( | 45 .then((response) => response.drain().then( |
| 45 (_) => response.headers)); | 46 (_) => response.headers)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 | 49 |
| 49 Future<String> getAsString(int port, String path) { | 50 Future<String> getAsString(int port, String path) { |
| 50 return new HttpClient().get('localhost', port, path) | 51 return new HttpClient().get('localhost', port, path) |
| 51 .then((request) => request.close()) | 52 .then((request) => request.close()) |
| 52 .then((response) => StringDecoder.decode(response)); | 53 .then((response) => UTF8.decodeStream(response)); |
| 53 } | 54 } |
| 54 | 55 |
| 55 | 56 |
| 56 const CERTIFICATE = "localhost_cert"; | 57 const CERTIFICATE = "localhost_cert"; |
| 57 | 58 |
| 58 | 59 |
| 59 setupSecure() { | 60 setupSecure() { |
| 60 String scriptDir = dirname(new Options().script); | 61 String scriptDir = dirname(new Options().script); |
| 61 String certificateDatabase = join(scriptDir, 'pkcert'); | 62 String certificateDatabase = join(scriptDir, 'pkcert'); |
| 62 SecureSocket.initialize(database: certificateDatabase, | 63 SecureSocket.initialize(database: certificateDatabase, |
| 63 password: 'dartdart'); | 64 password: 'dartdart'); |
| 64 } | 65 } |
| OLD | NEW |