cloud-setup: make nm_http_client_req() accept a method argument

We'll need to be able to issue PUT calls.

Conflicts: variable alignments only, missing nmcs-provider-aliyun

(cherry picked from commit cd74d75002)
(cherry picked from commit eff4372045)
(cherry picked from commit aaf66e9174)
(cherry picked from commit 3d94f4fdf9)
(cherry picked from commit 181466c6da)
(cherry picked from commit 7243307bb8)
(cherry picked from commit 1aa88024cb)
This commit is contained in:
Lubomir Rintel 2023-02-27 00:13:31 +01:00 committed by Íñigo Huguet
parent 89ee76409b
commit 59b5a8fdcb
5 changed files with 24 additions and 0 deletions

View file

@ -262,6 +262,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)
@ -322,6 +323,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,
@ -397,6 +401,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;
@ -434,6 +439,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);
@ -520,6 +526,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,

View file

@ -39,6 +39,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,

View file

@ -84,6 +84,7 @@ detect(NMCSProvider *provider, GTask *task)
7000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
g_task_get_cancellable(task),
NULL,
NULL,
@ -302,6 +303,7 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u
10000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -324,6 +326,7 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u
10000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -341,6 +344,7 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u
10000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -423,6 +427,7 @@ _get_config_iface_cb(GObject *source, GAsyncResult *result, gpointer user_data)
10000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -523,6 +528,7 @@ _get_net_ifaces_list_cb(GObject *source, GAsyncResult *result, gpointer user_dat
10000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -546,6 +552,7 @@ get_config(NMCSProvider *provider, NMCSProviderGetConfigTaskData *get_config_dat
15000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,

View file

@ -120,6 +120,7 @@ detect(NMCSProvider *provider, GTask *task)
7000,
1000,
NULL,
NULL,
g_task_get_cancellable(task),
_detect_get_meta_data_check_cb,
NULL,
@ -281,6 +282,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -298,6 +300,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -395,6 +398,7 @@ get_config(NMCSProvider *provider, NMCSProviderGetConfigTaskData *get_config_dat
15000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
_get_config_metadata_ready_check,
get_config_data,

View file

@ -79,6 +79,7 @@ detect(NMCSProvider *provider, GTask *task)
7000,
1000,
NM_MAKE_STRV(NM_GCP_METADATA_HEADER),
NULL,
g_task_get_cancellable(task),
NULL,
NULL,
@ -227,6 +228,7 @@ _get_config_ips_list_cb(GObject *source, GAsyncResult *result, gpointer user_dat
HTTP_POLL_TIMEOUT_MS,
HTTP_RATE_LIMIT_MS,
NM_MAKE_STRV(NM_GCP_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -313,6 +315,7 @@ _get_config_iface_cb(GObject *source, GAsyncResult *result, gpointer user_data)
HTTP_POLL_TIMEOUT_MS,
HTTP_RATE_LIMIT_MS,
NM_MAKE_STRV(NM_GCP_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -412,6 +415,7 @@ _get_net_ifaces_list_cb(GObject *source, GAsyncResult *result, gpointer user_dat
HTTP_POLL_TIMEOUT_MS,
HTTP_RATE_LIMIT_MS,
NM_MAKE_STRV(NM_GCP_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -435,6 +439,7 @@ get_config(NMCSProvider *provider, NMCSProviderGetConfigTaskData *get_config_dat
HTTP_POLL_TIMEOUT_MS,
HTTP_RATE_LIMIT_MS,
NM_MAKE_STRV(NM_GCP_METADATA_HEADER),
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,