Skip to content
Snippets Groups Projects
Commit 66758349 authored by Frederic Danis's avatar Frederic Danis
Browse files

Use AhaHawkbitSession to download artifact


Artifact download needs the authentication token which is managed by
AhaHawkbitSession.

Signed-off-by: default avatarFrédéric Danis <frederic.danis@collabora.com>
parent 88d45cc0
No related branches found
No related tags found
1 merge request!1Initial support for Apertis hawkBit agent
......@@ -19,14 +19,13 @@ download_got_chunk (SoupMessage *message,
}
static void
download_uri (const char *uri, const gchar *filename)
download_uri (AhaHawkbitSession *hb_session, const char *uri, const gchar *filename)
{
guint status;
g_autoptr (SoupSession) session =
soup_session_new_with_options (SOUP_SESSION_USER_AGENT,
"Apertis Hawkbit Agent",
NULL);
g_autoptr (SoupMessage) msg = soup_message_new (SOUP_METHOD_GET, uri);
g_autoptr (SoupMessage) msg = aha_hawkbit_session_create_message_for_uri (
hb_session,
SOUP_METHOD_GET,
uri);
g_autoptr (GFile) f = g_file_new_for_path (filename);
g_autoptr (GFileIOStream) io = g_file_replace_readwrite (f, NULL,
FALSE,
......@@ -40,7 +39,9 @@ download_uri (const char *uri, const gchar *filename)
G_CALLBACK (download_got_chunk),
out);
status = soup_session_send_message (session, msg);
status = soup_session_send_message (
aha_hawkbit_session_get_soup_session (hb_session),
msg);
g_print("=> %d\n", status);
g_print("=> %s\n", msg->response_body->data);
g_output_stream_close (out, NULL, NULL);
......@@ -79,7 +80,7 @@ main(int argc, char **argv) {
if (u_uri == NULL)
return 0;
download_uri (u_uri, u_filename);
download_uri (hb_session, u_uri, u_filename);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment