Skip to content

Commit 42f2d73

Browse files
authored
Merge pull request #40 from ityuhui/yh-progress-function
Re-generate the client to merge the progress function support from openapi-generator PR#7974
2 parents 3bdbebc + 77f227d commit 42f2d73

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

kubernetes/include/apiClient.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <stdio.h>
77
#include <stdbool.h>
88
#include <stdint.h>
9+
#include <curl/curl.h>
910
#include "../include/list.h"
1011
#include "../include/keyValuePair.h"
1112
#include "../include/binary.h"
@@ -24,6 +25,8 @@ typedef struct apiClient_t {
2425
void *dataReceived;
2526
long dataReceivedLen;
2627
void (*data_callback_func)(void **, long *);
28+
int (*progress_func)(void *, curl_off_t, curl_off_t, curl_off_t, curl_off_t);
29+
void *progress_data;
2730
long response_code;
2831
list_t *apiKeys_BearerToken;
2932
} apiClient_t;

kubernetes/src/apiClient.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ apiClient_t *apiClient_create() {
1313
apiClient->dataReceived = NULL;
1414
apiClient->dataReceivedLen = 0;
1515
apiClient->data_callback_func = NULL;
16+
apiClient->progress_func = NULL;
17+
apiClient->progress_data = NULL;
1618
apiClient->response_code = 0;
1719
apiClient->apiKeys_BearerToken = NULL;
1820

@@ -39,6 +41,8 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
3941
apiClient->dataReceived = NULL;
4042
apiClient->dataReceivedLen = 0;
4143
apiClient->data_callback_func = NULL;
44+
apiClient->progress_func = NULL;
45+
apiClient->progress_data = NULL;
4246
apiClient->response_code = 0;
4347
if(apiKeys_BearerToken!= NULL) {
4448
apiClient->apiKeys_BearerToken = list_create();
@@ -60,6 +64,8 @@ void apiClient_free(apiClient_t *apiClient) {
6064
free(apiClient->basePath);
6165
}
6266
apiClient->data_callback_func = NULL;
67+
apiClient->progress_func = NULL;
68+
apiClient->progress_data = NULL;
6369
if(apiClient->apiKeys_BearerToken) {
6470
listEntry_t *listEntry = NULL;
6571
list_ForEach(listEntry, apiClient->apiKeys_BearerToken) {
@@ -383,6 +389,14 @@ void apiClient_invoke(apiClient_t *apiClient,
383389
}
384390
}
385391

392+
if (apiClient->progress_func != NULL) {
393+
curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, apiClient->progress_func);
394+
if (apiClient->progress_data != NULL) {
395+
curl_easy_setopt(handle, CURLOPT_XFERINFODATA, apiClient->progress_data);
396+
}
397+
curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0L);
398+
}
399+
386400
// this would only be generated for apiKey authentication
387401
if (apiClient->apiKeys_BearerToken != NULL)
388402
{

0 commit comments

Comments
 (0)