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

We'll need to be able to issue PUT calls.
This commit is contained in:
Lubomir Rintel
2023-02-27 00:13:31 +01:00
parent 85ce088616
commit cd74d75002
6 changed files with 31 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

@@ -40,6 +40,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,
@@ -366,6 +367,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 +385,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@@ -400,6 +403,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@@ -417,6 +421,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@@ -434,6 +439,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@@ -531,6 +537,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,
@@ -264,6 +265,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@@ -281,6 +283,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
10000,
1000,
NULL,
NULL,
get_config_data->intern_cancellable,
NULL,
NULL,
@@ -378,6 +381,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,