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

Side by Side Diff: runtime/bin/builtin.dart

Issue 15966002: Add support for loading scripts from http (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 builtin; 5 library builtin;
6 import 'dart:uri'; 6 import 'dart:uri';
7 7
8 // Corelib 'print' implementation. 8 // Corelib 'print' implementation.
9 void _print(arg) { 9 void _print(arg) {
10 _Logger._printString(arg.toString()); 10 _Logger._printString(arg.toString());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 switch (uri.scheme) { 101 switch (uri.scheme) {
102 case 'file': 102 case 'file':
103 path = _filePathFromFileUri(uri); 103 path = _filePathFromFileUri(uri);
104 break; 104 break;
105 case 'dart-ext': 105 case 'dart-ext':
106 path = _filePathFromOtherUri(uri); 106 path = _filePathFromOtherUri(uri);
107 break; 107 break;
108 case 'package': 108 case 'package':
109 path = _filePathFromPackageUri(uri); 109 path = _filePathFromPackageUri(uri);
110 break; 110 break;
111 case 'http':
112 path = _filePathFromHttpUri(uri);
113 break;
111 default: 114 default:
112 // Only handling file and package URIs in standalone binary. 115 // Only handling file and package URIs in standalone binary.
113 _logResolution("# Unknown scheme (${uri.scheme}) in $uri."); 116 _logResolution("# Unknown scheme (${uri.scheme}) in $uri.");
114 throw "Not a known scheme: $uri"; 117 throw "Not a known scheme: $uri";
115 } 118 }
116 119
117 if (isWindows && path.startsWith("/")) { 120 if (isWindows && path.startsWith("/")) {
118 // For Windows we need to massage the paths a bit according to 121 // For Windows we need to massage the paths a bit according to
119 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx 122 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
120 // 123 //
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 var path; 160 var path;
158 if (_packageRoot != null) { 161 if (_packageRoot != null) {
159 path = "${_packageRoot}${uri.path}"; 162 path = "${_packageRoot}${uri.path}";
160 } else { 163 } else {
161 path = _entrypoint.resolve('packages/${uri.path}').path; 164 path = _entrypoint.resolve('packages/${uri.path}').path;
162 } 165 }
163 166
164 _logResolution("# Package: $path"); 167 _logResolution("# Package: $path");
165 return path; 168 return path;
166 } 169 }
170
171 String _filePathFromHttpUri(Uri uri) {
172 _logResolution('# Path: $uri');
173 return uri.toString();
174 }
175
176 String _pathFromHttpUri(String userUri) {
177 var uri = Uri.parse(userUri);
178 return uri.path;
179 }
180
181 String _domainFromHttpUri(String userUri) {
182 var uri = Uri.parse(userUri);
183 return uri.domain;
184 }
185
186 int _portFromHttpUri(String userUri) {
187 var uri = Uri.parse(userUri);
188 return uri.port == 0 ? 80 : uri.port;
189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698