Refactor cURL use into helper functions with local handles #92
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Most curl requests are now done through new helper functions in
rest_vol.c
,RV_curl_post
,RV_curl_put
RV_curl_delete
, andRV_curl_get
. These functions each create a local curl handle, perform the request, then clean up the handle afterwards.In order to allow for cases where specific error codes are OK or even expected (checking for the existence of files, flush requests that expect to get HTTP 204 NO CONTENT) the curl helpers return the HTTP code that the request returned, or -1 if the request failed.
The curl helper functions take in the server's base URL through the
server_info_t
struct, so they only need the endpoint as a separate argument. For this reason, most instances ofrequest_url
have been changed torequest_endpoint
, and no longer include the base URL. Thisrequest_endpoint
is what is passed to the curl helpers.I also introduced a new global variable
H5_rest_curl_initialized_g
to track if curl is initialized. This avoids not-initializing or double-initializing it in the new helper to create a curl handle,RV_curl_setup_handle
.Places that still use the global curl handle:
H5_rest_authenticate_with_AD
since I'm not sure how to test itRV_curl_multi_perform
This is a draft PR since it's based on the branch that stores server connection information on individual file objects (#86).