d297b12fb89afeea5398f1600c15db7c2935d80b introduced eager curl handle initialization and its further reusage to leverage from connection caching.
It's definitely a movement into right direction but current code has a problem: it removes all the presets from the handle with curl_easy_reset (though it doesn't reset caches).
There's currently a bug that resets progress callback been set in session_alloc.
I propose to move the initialization of option defaults and all the options which are not request-specific to session_alloc and apply it to another handle called base_handle.
Then, each request builds a duplicate of that base_handle and sets request-specific options on it. Connection cache is being shared using curl shared objects.
Further, I'd like to refactor set_options_from_request function to avoid handle duplication at all in cases when no options are overriden on request level. It'd require to rewrite all Session option accessors to modify on base_handle directly so all the session-level options will already be applied and less work needs to be done on each request.
d297b12fb89afeea5398f1600c15db7c2935d80b introduced eager curl handle initialization and its further reusage to leverage from connection caching.
It's definitely a movement into right direction but current code has a problem: it removes all the presets from the handle with
curl_easy_reset
(though it doesn't reset caches).There's currently a bug that resets progress callback been set in
session_alloc
.I propose to move the initialization of option defaults and all the options which are not request-specific to
session_alloc
and apply it to another handle calledbase_handle
.Then, each request builds a duplicate of that
base_handle
and sets request-specific options on it. Connection cache is being shared using curl shared objects.Further, I'd like to refactor
set_options_from_request
function to avoid handle duplication at all in cases when no options are overriden on request level. It'd require to rewrite allSession
option accessors to modify onbase_handle
directly so all the session-level options will already be applied and less work needs to be done on each request.Handle duplication: https://curl.se/libcurl/c/curl_easy_duphandle.html Shared objects: https://curl.se/libcurl/c/curl_share_init.html