From fead8b897e9815328dff7e3d288c5af168d5c864 Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Tue, 16 Aug 2022 00:01:26 +0000 Subject: [PATCH] [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 Commit-Queue: Sigmund Cherem --- CHANGELOG.md | 5 +++ .../lib/src/source_file_provider.dart | 41 ------------------- 2 files changed, 5 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9fea4fe9ac..b84f4917e52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart index 8813a7f607e..667f25fa76c 100644 --- a/pkg/compiler/lib/src/source_file_provider.dart +++ b/pkg/compiler/lib/src/source_file_provider.dart @@ -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>> _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> splitContent) { - int totalLength = splitContent.fold(0, (int old, List list) { - return old + list.length; - }); - Uint8List result = Uint8List(totalLength); - int offset = 0; - for (List contentPart in splitContent) { - result.setRange(offset, offset + contentPart.length, contentPart); - offset += contentPart.length; - } - dartCharactersRead += totalLength; - api.Input> 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> getUtf8SourceFile(Uri resourceUri) {