X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ntsimulator%2Fntsim-ng%2Futils%2Fhttp_client.c;h=bc01d4f656556cb49905ff5180f47a4d44832d45;hb=32ee75567ef99fe24669b282297353eb1b6dd4f7;hp=dd15a6d81584d14154cdd5e686f8dc7534b8a135;hpb=338a7e9c4ad76118e73cfda7bc6241d628e1c925;p=sim%2Fo1-interface.git diff --git a/ntsimulator/ntsim-ng/utils/http_client.c b/ntsimulator/ntsim-ng/utils/http_client.c index dd15a6d..bc01d4f 100644 --- a/ntsimulator/ntsim-ng/utils/http_client.c +++ b/ntsimulator/ntsim-ng/utils/http_client.c @@ -33,7 +33,7 @@ struct memory { }; static size_t curl_write_cb(void *data, size_t size, size_t nmemb, void *userp); - + int http_request(const char *url, const char *username, const char* password, const char *method, const char *send_data, int *response_code, char **recv_data) { assert(url); assert(method); @@ -65,10 +65,13 @@ int http_request(const char *url, const char *username, const char* password, co return NTS_ERR_FAILED; } + int curl_connect_timeout = get_int_from_string_with_default(getenv("CURL_CONNECT_TIMEOUT"), 1); + int curl_operation_timeout = get_int_from_string_with_default(getenv("CURL_OPERATION_TIMEOUT"), 1); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 1L); //seconds timeout for a connection - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1L); //seconds timeout for an operation - curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, (long)curl_connect_timeout); //seconds timeout for a connection + curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)curl_operation_timeout); //seconds timeout for an operation + curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, (long)curl_connect_timeout); curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); // disable SSL verifications @@ -99,7 +102,7 @@ int http_request(const char *url, const char *username, const char* password, co curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_cb); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response_data); } - + log_add_verbose(2, "%s-ing cURL to url=\"%s\" with body=\"%s\"... ", method, url, send_data_good); CURLcode res = curl_easy_perform(curl); curl_slist_free_all(header); @@ -175,7 +178,7 @@ int http_socket_request(const char *url, const char *sock_fname, const char *met curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_cb); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response_data); } - + log_add_verbose(2, "%s-ing cURL to url=\"%s\" with body=\"%s\"\n", method, url, send_data_good); CURLcode res = curl_easy_perform(curl); curl_slist_free_all(header);