@@ -10,6 +10,7 @@ apiClient_t *apiClient_create() {
1010 apiClient_t * apiClient = malloc (sizeof (apiClient_t ));
1111 apiClient -> basePath = strdup ("http://petstore.swagger.io/v2" );
1212 apiClient -> sslConfig = NULL ;
13+ apiClient -> curlConfig = NULL ;
1314 apiClient -> dataReceived = NULL ;
1415 apiClient -> dataReceivedLen = 0 ;
1516 apiClient -> data_callback_func = NULL ;
@@ -39,6 +40,12 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
3940 apiClient -> sslConfig = NULL ;
4041 }
4142
43+ apiClient -> curlConfig = malloc (sizeof (curlConfig_t ));
44+ apiClient -> curlConfig -> verbose = 0 ;
45+ apiClient -> curlConfig -> keepalive = 0 ;
46+ apiClient -> curlConfig -> keepidle = 120 ;
47+ apiClient -> curlConfig -> keepintvl = 60 ;
48+
4249 apiClient -> dataReceived = NULL ;
4350 apiClient -> dataReceivedLen = 0 ;
4451 apiClient -> data_callback_func = NULL ;
@@ -85,6 +92,12 @@ void apiClient_free(apiClient_t *apiClient) {
8592 }
8693 list_freeList (apiClient -> apiKeys_api_key );
8794 }
95+
96+ if (apiClient -> curlConfig ) {
97+ free (apiClient -> curlConfig );
98+ apiClient -> curlConfig = NULL ;
99+ }
100+
88101 free (apiClient );
89102}
90103
@@ -413,6 +426,12 @@ void apiClient_invoke(apiClient_t *apiClient,
413426 operationParameter ,
414427 queryParameters );
415428
429+ if (apiClient -> curlConfig -> keepalive == 1 ) {
430+ curl_easy_setopt (handle , CURLOPT_TCP_KEEPALIVE , 1L );
431+ curl_easy_setopt (handle , CURLOPT_TCP_KEEPIDLE , apiClient -> curlConfig -> keepidle );
432+ curl_easy_setopt (handle , CURLOPT_TCP_KEEPINTVL , apiClient -> curlConfig -> keepintvl );
433+ }
434+
416435 curl_easy_setopt (handle , CURLOPT_URL , targetUrl );
417436 curl_easy_setopt (handle ,
418437 CURLOPT_WRITEFUNCTION ,
@@ -421,7 +440,7 @@ void apiClient_invoke(apiClient_t *apiClient,
421440 CURLOPT_WRITEDATA ,
422441 apiClient );
423442 curl_easy_setopt (handle , CURLOPT_HTTPHEADER , headers );
424- curl_easy_setopt (handle , CURLOPT_VERBOSE , 0 ); // to get curl debug msg 0: to disable, 1L:to enable
443+ curl_easy_setopt (handle , CURLOPT_VERBOSE , apiClient -> curlConfig -> verbose );
425444
426445 // this would only be generated for OAuth2 authentication
427446 if (apiClient -> accessToken != NULL ) {
0 commit comments