From 4e13361c8e471822613cfad65e5b39f8ec6b91b7 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Mon, 8 May 2017 09:46:35 -0500 Subject: [PATCH] pull: Allow additional HTTP headers for summary fetch Read the http-headers (a(ss)) option in ostree_repo_remote_fetch_summary_with_options like ostree_repo_pull_with_options and add the headers to the fetcher. This allows things like providing additional authorization headers to the HTTP requests. Closes: #839 Approved by: cgwalters --- src/libostree/ostree-repo-pull.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 87f57e18..7929b91a 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -2460,10 +2460,14 @@ repo_remote_fetch_summary (OstreeRepo *self, gboolean ret = FALSE; gboolean from_cache = FALSE; const char *url_override = NULL; + g_autoptr(GVariant) extra_headers = NULL; g_autoptr(GPtrArray) mirrorlist = NULL; if (options) - (void) g_variant_lookup (options, "override-url", "&s", &url_override); + { + (void) g_variant_lookup (options, "override-url", "&s", &url_override); + (void) g_variant_lookup (options, "http-headers", "@a(ss)", &extra_headers); + } mainctx = g_main_context_new (); g_main_context_push_thread_default (mainctx); @@ -2472,6 +2476,9 @@ repo_remote_fetch_summary (OstreeRepo *self, if (fetcher == NULL) goto out; + if (extra_headers) + _ostree_fetcher_set_extra_headers (fetcher, extra_headers); + { g_autofree char *url_string = NULL; if (metalink_url_string) @@ -3584,6 +3591,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, * The following are currently defined: * * - override-url (s): Fetch summary from this URL if remote specifies no metalink in options + * - http-headers (a(ss)): Additional headers to add to all HTTP requests * * Returns: %TRUE on success, %FALSE on failure */