From: Michael Tremer Date: Thu, 19 Oct 2023 20:32:53 +0000 (+0000) Subject: downloader: Allow access to the effective URL X-Git-Tag: 0.9.30~1440 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8d7d6a59606fdcf64fa107823f0c2ffb5657490;p=pakfire.git downloader: Allow access to the effective URL Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/downloader.c b/src/libpakfire/downloader.c index 57b34e2b4..f437e02b1 100644 --- a/src/libpakfire/downloader.c +++ b/src/libpakfire/downloader.c @@ -101,6 +101,9 @@ struct pakfire_transfer { struct pakfire_mirrorlist* mirrors; struct pakfire_mirror* mirror; + // Effective URL + const char* effective_url; + // Authentication unsigned int auth; }; @@ -534,6 +537,10 @@ int pakfire_downloader_transfer_set_baseurl( return pakfire_string_set(transfer->baseurl, baseurl); } +const char* pakfire_downloader_transfer_get_effective_url(struct pakfire_transfer* transfer) { + return transfer->effective_url; +} + int pakfire_downloader_transfer_set_mirrorlist( struct pakfire_transfer* transfer, struct pakfire_mirrorlist* mirrors) { if (transfer->mirrors) @@ -847,7 +854,6 @@ static int pakfire_transfer_done(struct pakfire_downloader* downloader, CURL* h = transfer->handle; int r; char* scheme = NULL; - const char* url; long response_code; long http_version; double total_time; @@ -876,9 +882,9 @@ static int pakfire_transfer_done(struct pakfire_downloader* downloader, curl_easy_getinfo(h, CURLINFO_SCHEME, &scheme); // Effective URL - curl_easy_getinfo(h, CURLINFO_EFFECTIVE_URL, &url); - if (url) - CTX_DEBUG(downloader->ctx, " Effective URL: %s\n", url); + curl_easy_getinfo(h, CURLINFO_EFFECTIVE_URL, &transfer->effective_url); + if (transfer->effective_url) + CTX_DEBUG(downloader->ctx, " Effective URL: %s\n", transfer->effective_url); // Response code curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &response_code); @@ -923,7 +929,7 @@ static int pakfire_transfer_done(struct pakfire_downloader* downloader, char* expected_hexdigest = __pakfire_hexlify(transfer->expected_digest, transfer->expected_digest_length); - CTX_ERROR(downloader->ctx, "Download checksum for %s didn't match:\n", url); + CTX_ERROR(downloader->ctx, "Download checksum for %s didn't match:\n", transfer->effective_url); CTX_ERROR(downloader->ctx, " Expected: %s\n", expected_hexdigest); CTX_ERROR(downloader->ctx, " Computed: %s\n", computed_hexdigest); diff --git a/src/libpakfire/include/pakfire/downloader.h b/src/libpakfire/include/pakfire/downloader.h index f4b9061bd..aed84475a 100644 --- a/src/libpakfire/include/pakfire/downloader.h +++ b/src/libpakfire/include/pakfire/downloader.h @@ -50,6 +50,7 @@ int pakfire_downloader_transfer_set_title( struct pakfire_transfer* transfer, const char* title); int pakfire_downloader_transfer_set_baseurl( struct pakfire_transfer* transfer, const char* baseurl); +const char* pakfire_downloader_transfer_get_effective_url(struct pakfire_transfer* transfer); int pakfire_downloader_transfer_set_mirrorlist( struct pakfire_transfer* transfer, struct pakfire_mirrorlist* mirrors); int pakfire_downloader_transfer_set_size(