| 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 /// Runs a HTTP server on localhost that mimics the behavoir of pub.dartlang.org | 5 /// Runs a HTTP server on localhost that mimics the behavoir of pub.dartlang.org |
| 6 /// and serves files on pub requests. Files to be stored are on disk in the file | 6 /// and serves files on pub requests. Files to be stored are on disk in the file |
| 7 /// system. | 7 /// system. |
| 8 /// | 8 /// |
| 9 /// The port for the server and the base directory of the data to be served | 9 /// The port for the server and the base directory of the data to be served |
| 10 /// should be passed in as arguments | 10 /// should be passed in as arguments |
| 11 | 11 |
| 12 library pub_package_server; | 12 library pub_package_server; |
| 13 | 13 |
| 14 import 'dart:async'; | 14 import 'dart:async'; |
| 15 import 'dart:io'; | 15 import 'dart:io'; |
| 16 import 'dart:json' as json; | |
| 17 | 16 |
| 18 const LOG_REQUESTS = true; | 17 const LOG_REQUESTS = true; |
| 19 | 18 |
| 20 String baseDir; | 19 String baseDir; |
| 21 | 20 |
| 22 main() { | 21 main() { |
| 23 int port; | 22 int port; |
| 24 var options = new Options().arguments; | 23 var options = new Options().arguments; |
| 25 if (options.length != 1) { | 24 if (options.length != 1) { |
| 26 print('Insufficient arguments \npub_package_server serverDataLocation'); | 25 print('Insufficient arguments \npub_package_server serverDataLocation'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 response.close(); | 65 response.close(); |
| 67 }); | 66 }); |
| 68 } catch (e) { | 67 } catch (e) { |
| 69 print(e); | 68 print(e); |
| 70 response.statusCode = 500; | 69 response.statusCode = 500; |
| 71 response.close(); | 70 response.close(); |
| 72 return; | 71 return; |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| OLD | NEW |