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

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

(cherry picked from commit cd74d75002)
(cherry picked from commit eff4372045)
(cherry picked from commit aaf66e9174)
(cherry picked from commit 3d94f4fdf9)
This commit is contained in:
Lubomir Rintel 2023-02-27 00:13:31 +01:00 committed by Íñigo Huguet
parent 4c846a112a
commit 181466c6da
6 changed files with 30 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)
@ -328,6 +329,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,
@ -403,6 +407,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;
@ -440,6 +445,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);
@ -526,6 +532,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

@ -111,6 +111,7 @@ detect(NMCSProvider *provider, GTask *task)
7000,
1000,
NULL,
NULL,
g_task_get_cancellable(task),
NULL,
NULL,
@ -332,6 +333,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -349,6 +351,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -366,6 +369,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -383,6 +387,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -480,6 +485,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

@ -76,6 +76,7 @@ detect(NMCSProvider *provider, GTask *task)
7000,
1000,
NM_MAKE_STRV(NM_AZURE_METADATA_HEADER),
NULL,
g_task_get_cancellable(task),
NULL,
NULL,
@ -294,6 +295,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,
@ -316,6 +318,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,
@ -333,6 +336,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,
@ -415,6 +419,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,
@ -515,6 +520,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,
@ -538,6 +544,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

@ -106,6 +106,7 @@ detect(NMCSProvider *provider, GTask *task)
7000,
1000,
NULL,
NULL,
g_task_get_cancellable(task),
_detect_get_meta_data_check_cb,
NULL,
@ -267,6 +268,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -284,6 +286,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@ -381,6 +384,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,