Trying to use header-based HTTP auth (not working)

This commit is contained in:
Imran Remtulla
2023-09-06 21:30:45 -04:00
parent 8ba0a0a776
commit c08e05bd6c
20 changed files with 81 additions and 66 deletions

View File

@@ -363,15 +363,23 @@ abstract class AppSource {
return url;
}
Map<String, String>? get requestHeaders => null;
Future<Map<String, String>?> getRequestHeaders(
{Map<String, dynamic> additionalSettings = const <String, dynamic>{},
bool forAPKDownload = false}) async {
return null;
}
Future<Response> sourceRequest(String url,
{bool followRedirects = true}) async {
{bool followRedirects = true,
Map<String, dynamic> additionalSettings =
const <String, dynamic>{}}) async {
var requestHeaders =
await getRequestHeaders(additionalSettings: additionalSettings);
if (requestHeaders != null || followRedirects == false) {
var req = Request('GET', Uri.parse(url));
req.followRedirects = followRedirects;
if (requestHeaders != null) {
req.headers.addAll(requestHeaders!);
req.headers.addAll(requestHeaders);
}
return Response.fromStream(await Client().send(req));
} else {