This PR implements caching of the cURL handle created by curl_init() to increase performance and reduce system overhead that comes with repeated creation and destruction of curl handles.
It modifies the getCurlHandle() method and only calls curl_init() once instead of each call to send(). It also removes now unnecessary calls to curl_close() in order to retain the pointer to the cached handle.
Calls to curl_init call curl_easy_init under the hood - the cURL documentation for curl_easy_init says "[You are]...encouraged to reuse easy handles for repeated transfers..." (see https://curl.se/libcurl/c/curl_easy_init.html). This PR implements this suggestion. The documentation for cURL also states "...reusing handles is a key to good performance with libcurl."
This PR implements caching of the cURL handle created by
curl_init()
to increase performance and reduce system overhead that comes with repeated creation and destruction of curl handles.It modifies the
getCurlHandle()
method and only callscurl_init()
once instead of each call tosend()
. It also removes now unnecessary calls tocurl_close()
in order to retain the pointer to the cached handle.Calls to
curl_init
callcurl_easy_init
under the hood - thecURL
documentation forcurl_easy_init
says "[You are]...encouraged to reuse easy handles for repeated transfers..." (see https://curl.se/libcurl/c/curl_easy_init.html). This PR implements this suggestion. The documentation for cURL also states "...reusing handles is a key to good performance with libcurl."@patinthehat