summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2023-04-24 16:53:11 +0300
committerTimo Teräs <timo.teras@iki.fi>2023-05-02 13:21:57 +0300
commit595b3745f1091e9e4b5ffeb256c9ba25b2533221 (patch)
tree428e765e40e855c0adc33afc1162770e37c7add6 /src
parent71ea076197410f7f1043762931b67338055a139e (diff)
downloadapk-tools-595b3745f1091e9e4b5ffeb256c9ba25b2533221.tar.gz
apk-tools-595b3745f1091e9e4b5ffeb256c9ba25b2533221.tar.bz2
apk-tools-595b3745f1091e9e4b5ffeb256c9ba25b2533221.tar.xz
apk-tools-595b3745f1091e9e4b5ffeb256c9ba25b2533221.zip
libfetch, apk: display warning for permanent redirects during init
fixes #10776
Diffstat (limited to 'src')
-rw-r--r--src/apk.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/apk.c b/src/apk.c
index 3baae46..3073584 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -488,6 +488,20 @@ static int remove_empty_strings(int count, char **args)
return j;
}
+static void fetch_redirect(int code, const struct url *cur, const struct url *next)
+{
+ char *url;
+
+ switch (code) {
+ case 301: // Moved Permanently
+ case 308: // Permanent Redirect
+ url = fetchStringifyURL(next);
+ apk_warning("Permanently redirected to %s", url);
+ free(url);
+ break;
+ }
+}
+
int main(int argc, char **argv)
{
void *ctx = NULL;
@@ -523,6 +537,7 @@ int main(int argc, char **argv)
init_openssl();
setup_automatic_flags();
fetchTimeout = 60;
+ fetchRedirectMethod = fetch_redirect;
fetchConnectionCacheInit(32, 4);
r = parse_options(argc, argv, applet, ctx, &dbopts);
@@ -601,6 +616,7 @@ int main(int argc, char **argv)
apk_string_array_resize(&args, argc);
memcpy(args->item, argv, argc * sizeof(*argv));
+ fetchRedirectMethod = NULL;
r = applet->main(ctx, &db, args);
signal(SIGINT, SIG_IGN);