1818#define PROJECT_CCDBAPI_H
1919
2020#include < string>
21+ #include < string_view>
2122#include < memory>
2223#include < map>
23- #include < curl/curl.h>
2424#include < TObject.h>
2525#include < TMessage.h>
2626#include " CCDB/CcdbObjectInfo.h"
3636class TJAlienCredentials ;
3737#endif
3838
39- #include " CCDB/CCDBDownloader.h"
39+ // libcurl and the downloader are implementation details of CcdbApi.cxx;
40+ // only opaque handles appear below, so neither header is needed here.
41+ struct curl_slist ;
4042
4143class TFile ;
42- class TGrid ;
44+ # include < TGrid.h >
4345
4446namespace o2
4547{
4648namespace ccdb
4749{
4850
4951class CCDBQuery ;
52+ class CCDBDownloader ;
5053
5154/* *
5255 * Interface to the CCDB.
@@ -56,6 +59,9 @@ class CCDBQuery;
5659 * @todo handle errors and exceptions
5760 * @todo extend code coverage
5861 */
62+ // / stands in for libcurl's `typedef void CURL` without including <curl/curl.h>
63+ using CurlHandle = void ;
64+
5965class CcdbApi // : public DatabaseInterface
6066{
6167 public:
@@ -341,7 +347,7 @@ class CcdbApi //: public DatabaseInterface
341347 * @param curl curl handler
342348 * @return
343349 */
344- static void curlSetSSLOptions (CURL * curl);
350+ static void curlSetSSLOptions (CurlHandle * curl);
345351
346352 TObject* retrieve (std::string const & path, std::map<std::string, std::string> const & metadata, long timestamp) const ;
347353
@@ -441,7 +447,7 @@ class CcdbApi //: public DatabaseInterface
441447 * @param handle CURL handle associated with the request.
442448 * @param requestCounter Pointer to the variable storing the number of requests to be done.
443449 */
444- void asynchPerform (CURL * handle, size_t * requestCounter) const ;
450+ void asynchPerform (CurlHandle * handle, size_t * requestCounter) const ;
445451
446452 // internal helper function to update a CCDB file with meta information
447453 static void updateMetaInformationInLocalFile (std::string const & filename, std::map<std::string, std::string> const * headers, CCDBQuery const * querysummary = nullptr );
@@ -477,7 +483,7 @@ class CcdbApi //: public DatabaseInterface
477483 * @param endValidityTimestamp End of validity. If omitted or negative, current timestamp + 1 day is used.
478484 * @return The full url to store an object (url / startValidity / endValidity / [metadata &]* )
479485 */
480- std::string getFullUrlForStorage (CURL * curl, const std::string& path, const std::string& objtype,
486+ std::string getFullUrlForStorage (CurlHandle * curl, const std::string& path, const std::string& objtype,
481487 const std::map<std::string, std::string>& metadata,
482488 long startValidityTimestamp = -1 , long endValidityTimestamp = -1 , int hostIndex = 0 ) const ;
483489
@@ -488,7 +494,7 @@ class CcdbApi //: public DatabaseInterface
488494 * @param timestamp When the object we retrieve must be valid. If omitted or negative, the current timestamp is used.
489495 * @return The full url to store an object (url / startValidity / endValidity / [metadata &]* )
490496 */
491- std::string getFullUrlForRetrieval (CURL * curl, const std::string& path, const std::map<std::string, std::string>& metadata,
497+ std::string getFullUrlForRetrieval (CurlHandle * curl, const std::string& path, const std::map<std::string, std::string>& metadata,
492498 long timestamp = -1 , int hostIndex = 0 ) const ;
493499
494500 public:
@@ -563,25 +569,24 @@ class CcdbApi //: public DatabaseInterface
563569
564570 // / Queries the CCDB server and navigates through possible redirects until binary content is found; Retrieves content as instance
565571 // / given by tinfo if that is possible. Returns nullptr if something fails...
566- void * navigateURLsAndRetrieveContent (CURL *, std::string const & url, std::type_info const & tinfo, std::map<std::string, std::string>* headers) const ;
572+ void * navigateURLsAndRetrieveContent (CurlHandle *, std::string const & url, std::type_info const & tinfo, std::map<std::string, std::string>* headers) const ;
567573
568574 // helper that interprets a content chunk as TMemFile and extracts the object therefrom
569575 static void * interpretAsTMemFileAndExtract (char * contentptr, size_t contentsize, std::type_info const & tinfo);
570576
571577 /* *
572- * Initialization of CURL
573- */
578+ * Initialization of CurlHandle*/
574579 void curlInit ();
575580
576581 // convert type_info to TClass, throw on failure
577582 static TClass* tinfo2TClass (std::type_info const & tinfo);
578583
579584 typedef size_t (*CurlWriteCallback)(void *, size_t , size_t , void *);
580585
581- void initCurlOptionsForRetrieve (CURL * curlHandle, void * pointer, CurlWriteCallback writeCallback, bool followRedirect = true ) const ;
586+ void initCurlOptionsForRetrieve (CurlHandle * curlHandle, void * pointer, CurlWriteCallback writeCallback, bool followRedirect = true ) const ;
582587
583588 // / initialize HTTPS header information for the CURL handle. Needs to be given an existing curl_slist* pointer to work with (may be nullptr), which needs to be free by the caller.
584- void initCurlHTTPHeaderOptionsForRetrieve (CURL * curlHandle, curl_slist*& option_list, long timestamp, std::map<std::string, std::string>* headers, std::string const & etag, const std::string& createdNotAfter, const std::string& createdNotBefore) const ;
589+ void initCurlHTTPHeaderOptionsForRetrieve (CurlHandle * curlHandle, curl_slist*& option_list, long timestamp, std::map<std::string, std::string>* headers, std::string const & etag, const std::string& createdNotAfter, const std::string& createdNotBefore, std::string_view url ) const ;
585590
586591 bool receiveToFile (FILE * fileHandle, std::string const & path, std::map<std::string, std::string> const & metadata,
587592 long timestamp, std::map<std::string, std::string>* headers = nullptr , std::string const & etag = " " ,
@@ -627,7 +632,7 @@ class CcdbApi //: public DatabaseInterface
627632
628633 // tmp helper and single point of entry for a CURL perform call
629634 // helps to switch between easy handle perform and multi handles in a single place
630- CURLcode CURL_perform (CURL * handle) const ;
635+ int CURL_perform (CurlHandle * handle) const ; // returns a CURLcode
631636
632637 mutable CCDBDownloader* mDownloader = nullptr ; // ! the multi-handle (async) CURL downloader
633638 bool mIsCCDBDownloaderPreferred = false ;
0 commit comments