[dart2js] remove support for reading sources from http (tech-debt)

Long ago the compiler had logic for reading sources via an http
connection. This is not a supported use case and there is no need to
keep this around anymore.

Change-Id: Ic59c154def264a52d9310133f76b153c9972899c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251701
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Sigmund Cherem 2022-08-16 00:01:26 +00:00 committed by Commit Bot
parent cccc959dd4
commit fead8b897e
2 changed files with 5 additions and 41 deletions

View file

@ -79,6 +79,11 @@ Updated the Linter to `1.27.0`, which includes changes that
- Remove remaining support for `.packages` files. The flag
`--legacy-packages-file` is no longer supported.
#### dart2js
- **Breaking change** [49473](https://github.com/dart-lang/sdk/issues/49473):
dart2js no longer supports HTTP URIs as inputs.
### Core libraries
#### `dart:io`

View file

@ -34,8 +34,6 @@ abstract class SourceFileProvider implements api.CompilerInput {
if (resourceUri.isScheme('file')) {
return _readFromFile(resourceUri, inputKind);
} else if (resourceUri.isScheme('http') || resourceUri.isScheme('https')) {
return _readFromHttp(resourceUri, inputKind);
} else {
throw ArgumentError("Unknown scheme in uri '$resourceUri'");
}
@ -125,45 +123,6 @@ abstract class SourceFileProvider implements api.CompilerInput {
return Future.value(input);
}
Future<api.Input<List<int>>> _readFromHttp(
Uri resourceUri, api.InputKind inputKind) {
assert(resourceUri.isScheme('http'));
HttpClient client = HttpClient();
return client
.getUrl(resourceUri)
.then((HttpClientRequest request) => request.close())
.then((HttpClientResponse response) {
if (response.statusCode != HttpStatus.ok) {
String msg = 'Failure getting $resourceUri: '
'${response.statusCode} ${response.reasonPhrase}';
throw msg;
}
return response.toList();
}).then((List<List<int>> splitContent) {
int totalLength = splitContent.fold(0, (int old, List list) {
return old + list.length;
});
Uint8List result = Uint8List(totalLength);
int offset = 0;
for (List<int> contentPart in splitContent) {
result.setRange(offset, offset + contentPart.length, contentPart);
offset += contentPart.length;
}
dartCharactersRead += totalLength;
api.Input<List<int>> input;
switch (inputKind) {
case api.InputKind.UTF8:
input = utf8SourceFiles[resourceUri] = CachingUtf8BytesSourceFile(
resourceUri, resourceUri.toString(), result);
break;
case api.InputKind.binary:
input = binarySourceFiles[resourceUri] = Binary(resourceUri, result);
break;
}
return input;
});
}
relativizeUri(Uri uri) => fe.relativizeUri(cwd, uri, isWindows);
SourceFile<List<int>> getUtf8SourceFile(Uri resourceUri) {