From: Michael Tremer Date: Sun, 15 Sep 2024 02:52:53 +0000 (+0000) Subject: httpclient: Add option to set a base URL X-Git-Tag: 0.9.30~1199 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5508be93862734ed403ee2f369757b0806438836;p=pakfire.git httpclient: Add option to set a base URL Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/httpclient.c b/src/libpakfire/httpclient.c index 30fb64d2b..882b29d67 100644 --- a/src/libpakfire/httpclient.c +++ b/src/libpakfire/httpclient.c @@ -28,6 +28,7 @@ #include #include #include +#include #include // The number of concurrent downloads @@ -37,6 +38,9 @@ struct pakfire_httpclient { struct pakfire_ctx* ctx; int nrefs; + // Base URL + char baseurl[PATH_MAX]; + // Event Loop sd_event* loop; int still_running; @@ -479,6 +483,17 @@ CURLSH* pakfire_httpclient_share(struct pakfire_httpclient* client) { return client->share; } +const char* pakfire_httpclient_get_baseurl(struct pakfire_httpclient* client) { + if (*client->baseurl) + return client->baseurl; + + return NULL; +} + +int pakfire_httpclient_set_baseurl(struct pakfire_httpclient* client, const char* baseurl) { + return pakfire_string_set(client->baseurl, baseurl); +} + int pakfire_httpclient_create_xfer(struct pakfire_xfer** xfer, struct pakfire_httpclient* client, const char* url) { return pakfire_xfer_create(xfer, client->ctx, client, url); diff --git a/src/libpakfire/include/pakfire/httpclient.h b/src/libpakfire/include/pakfire/httpclient.h index 304cfe41b..43a579724 100644 --- a/src/libpakfire/include/pakfire/httpclient.h +++ b/src/libpakfire/include/pakfire/httpclient.h @@ -41,6 +41,9 @@ struct pakfire_httpclient* pakfire_httpclient_unref(struct pakfire_httpclient* d sd_event* pakfire_httpclient_loop(struct pakfire_httpclient* client); CURLSH* pakfire_httpclient_share(struct pakfire_httpclient* downloader); +const char* pakfire_httpclient_get_baseurl(struct pakfire_httpclient* client); +int pakfire_httpclient_set_baseurl(struct pakfire_httpclient* client, const char* baseurl); + int pakfire_httpclient_create_xfer(struct pakfire_xfer** xfer, struct pakfire_httpclient* downloader, const char* url);