From cfa4c680cf1387696aaf1323c702974f585d032a Mon Sep 17 00:00:00 2001 From: Achim Date: Mon, 19 Feb 2024 16:02:49 +0100 Subject: [PATCH 1/2] Set referer header for gitlab app source context There occur issues if a gitlab project refers in its release data to external hosted .apk file. In some cases (e.g. Aurora Store) download is not possible because cloudflare protection gives "forbidden" error. The referer header seems to pacify this cloudflare protection. Tested with Android 14 in an AVD emulator. Related to: #1397, #1389, #1384, #1382, #1381, #1380, #1359, #854, #785, #697 --- lib/app_sources/gitlab.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/app_sources/gitlab.dart b/lib/app_sources/gitlab.dart index 3e1e701e..d661a004 100644 --- a/lib/app_sources/gitlab.dart +++ b/lib/app_sources/gitlab.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:html/parser.dart'; @@ -104,6 +105,21 @@ class GitLab extends AppSource { String? changeLogPageFromStandardUrl(String standardUrl) => '$standardUrl/-/releases'; + @override + Future?> getRequestHeaders( + Map 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 = {}; + headers[HttpHeaders.refererHeader] = 'https://gitlab.com'; + if (headers.isNotEmpty) { + return headers; + } else { + return null; + } + } + @override Future getLatestAPKDetails( String standardUrl, From ef3b01ac56871cf6cccc66781c90355017a99bbe Mon Sep 17 00:00:00 2001 From: Achim Date: Mon, 26 Feb 2024 13:42:56 +0100 Subject: [PATCH 2/2] Use gitlab host defined in class member variable --- lib/app_sources/gitlab.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app_sources/gitlab.dart b/lib/app_sources/gitlab.dart index d661a004..8edf3594 100644 --- a/lib/app_sources/gitlab.dart +++ b/lib/app_sources/gitlab.dart @@ -112,7 +112,7 @@ class GitLab extends AppSource { // Change headers to pacify, e.g. cloudflare protection // Related to: (#1397, #1389, #1384, #1382, #1381, #1380, #1359, #854, #785, #697) var headers = {}; - headers[HttpHeaders.refererHeader] = 'https://gitlab.com'; + headers[HttpHeaders.refererHeader] = 'https://${hosts[0]}'; if (headers.isNotEmpty) { return headers; } else {