Skip to content

Commit

Permalink
Merge pull request #1411 from akramer-zibra/fix-gitlab-request-headers
Browse files Browse the repository at this point in the history
Solve issues with gitlab .apk files and cloudflare protection
  • Loading branch information
ImranR98 authored Feb 26, 2024
2 parents d13464a + ef3b01a commit 2c4713f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/app_sources/gitlab.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:html/parser.dart';
Expand Down Expand Up @@ -104,6 +105,21 @@ class GitLab extends AppSource {
String? changeLogPageFromStandardUrl(String standardUrl) =>
'$standardUrl/-/releases';

@override
Future<Map<String, String>?> getRequestHeaders(
Map<String, dynamic> additionalSettings,
{bool forAPKDownload = false}) async {
// Change headers to pacify, e.g. cloudflare protection
// Related to: (#1397, #1389, #1384, #1382, #1381, #1380, #1359, #854, #785, #697)
var headers = <String, String>{};
headers[HttpHeaders.refererHeader] = 'https://${hosts[0]}';
if (headers.isNotEmpty) {
return headers;
} else {
return null;
}
}

@override
Future<APKDetails> getLatestAPKDetails(
String standardUrl,
Expand Down

0 comments on commit 2c4713f

Please sign in to comment.