Skip to content

Commit

Permalink
Adding optional headers parameter to Http client request
Browse files Browse the repository at this point in the history
  • Loading branch information
blackgerman committed Feb 16, 2024
1 parent 212c232 commit 8c97caa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/src/appcast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class Appcast {
}

/// Download the Appcast from [appCastURL].
Future<List<AppcastItem>?> parseAppcastItemsFromUri(String appCastURL) async {
Future<List<AppcastItem>?> parseAppcastItemsFromUri(String appCastURL, {Map<String,String>? headers}) async {
http.Response response;
try {
response = await client.get(Uri.parse(appCastURL));
response = await client.get(Uri.parse(appCastURL), headers: headers);
} catch (e) {
print('upgrader: parseAppcastItemsFromUri exception: $e');
return null;
Expand Down
5 changes: 4 additions & 1 deletion lib/src/upgrader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ typedef UpgraderEvaluateNeed = bool;
/// names, such as "android", "fuchsia", "ios", "linux" "macos", "web", "windows".
class AppcastConfiguration {
final List<String>? supportedOS;
final Map<String, String>? headers;
final String? url;

AppcastConfiguration({
this.supportedOS,
this.headers,
this.url,
});
}
Expand Down Expand Up @@ -256,7 +258,8 @@ class Upgrader with WidgetsBindingObserver {
}

final appcast = this.appcast ?? Appcast(client: client);
await appcast.parseAppcastItemsFromUri(appcastConfig!.url!);
await appcast.parseAppcastItemsFromUri(appcastConfig!.url!,
headers: appcastConfig!.headers);
if (debugLogging) {
var count = appcast.items == null ? 0 : appcast.items!.length;
print('upgrader: appcast item count: $count');
Expand Down
2 changes: 1 addition & 1 deletion test/fake_appcast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FakeAppcast extends Fake implements TestAppcast {
}

@override
Future<List<AppcastItem>> parseAppcastItemsFromUri(String appCastURL) async {
Future<List<AppcastItem>> parseAppcastItemsFromUri(String appCastURL, {Map<String,String>? headers}) async {
callCount++;

return [AppcastItem()];
Expand Down

0 comments on commit 8c97caa

Please sign in to comment.