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

Unified Diff: runtime/bin/vmservice/loader.dart

Issue 1585103006: - Add support for passing data: based URIs as packageConfig to (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/tests/vm/vm.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/loader.dart
diff --git a/runtime/bin/vmservice/loader.dart b/runtime/bin/vmservice/loader.dart
index 6bc8c456093f2ef58fc92ecc7d38b105c5c86d36..9b7355e0b7ccad18fadf2d3fe8961877bdf15d54 100644
--- a/runtime/bin/vmservice/loader.dart
+++ b/runtime/bin/vmservice/loader.dart
@@ -64,12 +64,16 @@ void _loadFile(SendPort sp, int id, Uri uri) {
void _loadDataUri(SendPort sp, int id, Uri uri) {
try {
- if (uri.data.mimeType != "application/dart") {
- throw "MIME-type must be application/dart";
+ var mime = uri.data.mimeType;
+ if ((mime != "application/dart") &&
+ (mime != "text/plain")) {
+ throw "MIME-type must be application/dart or text/plain: $mime given.";
}
- if (uri.data.charset != "utf-8") {
+ var charset = uri.data.charset;
+ if ((charset != "utf-8") &&
+ (charset != "US-ASCII")) {
// The C++ portion of the embedder assumes UTF-8.
- throw "Only utf-8 encoding is supported";
+ throw "Only utf-8 or US-ASCII encodings are supported: $charset given.";
}
_sendResourceResponse(sp, id, uri.data.contentAsBytes());
} catch (e) {
@@ -262,7 +266,7 @@ _loadPackagesFile(SendPort sp, bool traceLoading, Uri packagesFile) async {
if (traceLoading) {
_log("Error loading packages: $e\n$s");
}
- sp.send("Uncaught error ($e) loading packags file.");
+ sp.send("Uncaught error ($e) loading packages file.");
}
}
@@ -364,6 +368,26 @@ Future<bool> _loadHttpPackagesFile(SendPort sp,
return false;
}
+_loadPackagesData(sp, traceLoading, resource){
+ try {
+ var data = resource.data;
+ var mime = data.mimeType;
+ if (mime != "text/plain") {
+ throw "MIME-type must be text/plain: $mime given.";
+ }
+ var charset = data.charset;
+ if ((charset != "utf-8") &&
+ (charset != "US-ASCII")) {
+ // The C++ portion of the embedder assumes UTF-8.
+ throw "Only utf-8 or US-ASCII encodings are supported: $charset given.";
+ }
+ _parsePackagesFile(sp, traceLoading, resource, data.contentAsBytes());
+ } catch (e) {
+ sp.send("Uncaught error ($e) loading packages data.");
+ }
+}
+
+
_handlePackagesRequest(SendPort sp,
bool traceLoading,
int id,
@@ -402,6 +426,8 @@ _handlePackagesRequest(SendPort sp,
if (!exists) {
sp.send("Packages file '$resource' not found.");
}
+ } else if (resource.scheme == 'data') {
+ _loadPackagesData(sp, traceLoading, resource);
} else {
sp.send("Unknown scheme (${resource.scheme}) for package file at "
"'$resource'.");
« no previous file with comments | « no previous file | runtime/tests/vm/vm.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698