Pass only Uri to package:http APIs (#74285)

This commit is contained in:
Nate Bosch 2021-01-20 09:59:03 -08:00 committed by GitHub
parent 5318782ac8
commit dcc4fdd558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 7 deletions

View File

@ -68,9 +68,8 @@ class StockData extends ChangeNotifier {
static const int _chunkCount = 30;
int _nextChunk = 0;
String _urlToFetch(int chunk) {
return 'https://domokit.github.io/examples/stocks/data/stock_data_$chunk.json';
}
Uri _urlToFetch(int chunk) => Uri.https(
'domokit.github.io', 'examples/stocks/data/stock_data_$chunk.json');
http.Client _httpClient;

View File

@ -170,7 +170,7 @@ class Cocoon {
/// Make an API request to Cocoon.
Future<Map<String, dynamic>> _sendCocoonRequest(String apiPath, [dynamic jsonData]) async {
final String url = '$baseCocoonApiUrl/$apiPath';
final Uri url = Uri.parse('$baseCocoonApiUrl/$apiPath');
/// Retry requests to Cocoon as sometimes there are issues with the servers, such
/// as version changes to the backend, datastore issues, or latency issues.

View File

@ -28,7 +28,7 @@ Future<void> main(List<String> args) async {
Future<Archive> fetchArchive(String url, int maxTries) async {
List<int> responseBytes;
for (int i = 0; i < maxTries; i++) {
final http.Response response = await http.get(url);
final http.Response response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
responseBytes = response.bodyBytes;
break;

View File

@ -53,9 +53,9 @@ class DevtoolsServerLauncher extends DevtoolsLauncher {
try {
const String pubHostedUrlKey = 'PUB_HOSTED_URL';
if (_platform.environment.containsKey(pubHostedUrlKey)) {
await http.head(_platform.environment[pubHostedUrlKey]);
await http.head(Uri.parse(_platform.environment[pubHostedUrlKey]));
} else {
await http.head('https://pub.dev');
await http.head(Uri.https('pub.dev', ''));
}
} on Exception {
offline = true;