Unverified Commit dcc4fdd5 authored by Nate Bosch's avatar Nate Bosch Committed by GitHub

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

parent 5318782a
...@@ -68,9 +68,8 @@ class StockData extends ChangeNotifier { ...@@ -68,9 +68,8 @@ class StockData extends ChangeNotifier {
static const int _chunkCount = 30; static const int _chunkCount = 30;
int _nextChunk = 0; int _nextChunk = 0;
String _urlToFetch(int chunk) { Uri _urlToFetch(int chunk) => Uri.https(
return 'https://domokit.github.io/examples/stocks/data/stock_data_$chunk.json'; 'domokit.github.io', 'examples/stocks/data/stock_data_$chunk.json');
}
http.Client _httpClient; http.Client _httpClient;
......
...@@ -170,7 +170,7 @@ class Cocoon { ...@@ -170,7 +170,7 @@ class Cocoon {
/// Make an API request to Cocoon. /// Make an API request to Cocoon.
Future<Map<String, dynamic>> _sendCocoonRequest(String apiPath, [dynamic jsonData]) async { 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 /// Retry requests to Cocoon as sometimes there are issues with the servers, such
/// as version changes to the backend, datastore issues, or latency issues. /// as version changes to the backend, datastore issues, or latency issues.
......
...@@ -28,7 +28,7 @@ Future<void> main(List<String> args) async { ...@@ -28,7 +28,7 @@ Future<void> main(List<String> args) async {
Future<Archive> fetchArchive(String url, int maxTries) async { Future<Archive> fetchArchive(String url, int maxTries) async {
List<int> responseBytes; List<int> responseBytes;
for (int i = 0; i < maxTries; i++) { 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) { if (response.statusCode == 200) {
responseBytes = response.bodyBytes; responseBytes = response.bodyBytes;
break; break;
......
...@@ -53,9 +53,9 @@ class DevtoolsServerLauncher extends DevtoolsLauncher { ...@@ -53,9 +53,9 @@ class DevtoolsServerLauncher extends DevtoolsLauncher {
try { try {
const String pubHostedUrlKey = 'PUB_HOSTED_URL'; const String pubHostedUrlKey = 'PUB_HOSTED_URL';
if (_platform.environment.containsKey(pubHostedUrlKey)) { if (_platform.environment.containsKey(pubHostedUrlKey)) {
await http.head(_platform.environment[pubHostedUrlKey]); await http.head(Uri.parse(_platform.environment[pubHostedUrlKey]));
} else { } else {
await http.head('https://pub.dev'); await http.head(Uri.https('pub.dev', ''));
} }
} on Exception { } on Exception {
offline = true; offline = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment