From eef7c66762ecd33c359ce165363ce513625f0e5e Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 27 Feb 2023 00:13:31 +0100 Subject: [PATCH] cloud-setup: make nm_http_client_req() accept a method argument We'll need to be able to issue PUT calls. Conflicts: code formatting, missing nmcs-provider-aliyun, azure and gcp. Missing commit 494819bbbf ("cloud-setup: move common code for get_config() to base class and improve cancellation") (cherry picked from commit cd74d75002783a79d1a4fca24b2fbe99ced933a8) (cherry picked from commit eff4372045290ad380bddf03e5075ab671a7cff6) (cherry picked from commit aaf66e9174eb04d2df1f45530ebdca16e77a6ec5) (cherry picked from commit 3d94f4fdf9f7f1fef6e8ec77593e4d3506d144df) (cherry picked from commit 181466c6dae4251f49596afb7abfc291b9769769) (cherry picked from commit 7243307bb8e4369aef8b0a68d64c2a05c47b0d8a) (cherry picked from commit 1aa88024cbf4720badb7b015c1f3a9be989eab70) (cherry picked from commit 59b5a8fdcb8c1dd33f9fd43ee9492aeaf8b1c186) (cherry picked from commit 0962b6e23da502827c3244c84b5c5aa371907e17) (cherry picked from commit b31caa6d6ae9f564d432a8a97ee54fc9ca286c63) (cherry picked from commit 10ff5f09572ecef8187bd1b814c20f4a92c2d20a) --- clients/cloud-setup/nm-http-client.c | 7 +++++++ clients/cloud-setup/nm-http-client.h | 1 + clients/cloud-setup/nmcs-provider-ec2.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/clients/cloud-setup/nm-http-client.c b/clients/cloud-setup/nm-http-client.c index 5daf9b356d..fdef04497e 100644 --- a/clients/cloud-setup/nm-http-client.c +++ b/clients/cloud-setup/nm-http-client.c @@ -265,6 +265,7 @@ nm_http_client_req (NMHttpClient *self, int timeout_msec, gssize max_data, const char *const *http_headers, + const char * http_method, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -326,6 +327,9 @@ nm_http_client_req (NMHttpClient *self, curl_easy_setopt (edata->ehandle, CURLOPT_HTTPHEADER, edata->headers); } + if (http_method) + curl_easy_setopt(edata->ehandle, CURLOPT_CUSTOMREQUEST, http_method); + if (timeout_msec > 0) { edata->timeout_source = _source_attach (self, nm_g_timeout_source_new (timeout_msec, @@ -387,6 +391,7 @@ typedef struct { GTask *task; char *uri; const char *const *http_headers; + const char *http_method; NMHttpClientPollReqCheckFcn check_fcn; gpointer check_user_data; GBytes *response_data; @@ -424,6 +429,7 @@ _poll_req_probe_start_fcn (GCancellable *cancellable, poll_req_data->request_timeout_ms, poll_req_data->request_max_data, poll_req_data->http_headers, + poll_req_data->http_method, cancellable, callback, user_data); @@ -504,6 +510,7 @@ nm_http_client_poll_req (NMHttpClient *self, int poll_timeout_ms, int ratelimit_timeout_ms, const char *const *http_headers, + const char *http_method, GCancellable *cancellable, NMHttpClientPollReqCheckFcn check_fcn, gpointer check_user_data, diff --git a/clients/cloud-setup/nm-http-client.h b/clients/cloud-setup/nm-http-client.h index eeca3930d2..6f5338fd86 100644 --- a/clients/cloud-setup/nm-http-client.h +++ b/clients/cloud-setup/nm-http-client.h @@ -37,6 +37,7 @@ void nm_http_client_poll_req (NMHttpClient *self, int poll_timeout_ms, int ratelimit_timeout_ms, const char *const *http_headers, + const char *http_method, GCancellable *cancellable, NMHttpClientPollReqCheckFcn check_fcn, gpointer check_user_data, diff --git a/clients/cloud-setup/nmcs-provider-ec2.c b/clients/cloud-setup/nmcs-provider-ec2.c index 5ef0b51fa9..4d92e1a778 100644 --- a/clients/cloud-setup/nmcs-provider-ec2.c +++ b/clients/cloud-setup/nmcs-provider-ec2.c @@ -139,6 +139,7 @@ detect (NMCSProvider *provider, 7000, 1000, NULL, + NULL, g_task_get_cancellable (task), _detect_get_meta_data_check_cb, NULL, @@ -398,6 +399,7 @@ _get_config_metadata_ready_cb (GObject *source, 10000, 1000, NULL, + NULL, iface_data->cancellable, NULL, NULL, @@ -416,6 +418,7 @@ _get_config_metadata_ready_cb (GObject *source, 10000, 1000, NULL, + NULL, iface_data->cancellable, NULL, NULL, @@ -533,6 +536,7 @@ get_config (NMCSProvider *provider, 15000, 1000, NULL, + NULL, g_task_get_cancellable (get_config_data->task), _get_config_metadata_ready_check, metadata_data,