class Curl

Defined at line 43 of file ../../src/developer/debug/zxdb/common/curl.h

To use Curl, one must add something like the following to the beginning of their main() function

(and include necessary header files).

Curl::GlobalInit();

auto deferred_cleanup = fit::defer([]{ Curl::GlobalCleanup(); });

This is due to the thread-unsafety of curl_global_init() and curl_global_cleanup(), see

https://curl.se/libcurl/c/curl_global_init.html and

https://curl.se/libcurl/c/curl_global_cleanup.html.

Curl must be constructed through fxl::MakeRefCounted

<Curl

>().

Example usage:

int main() {

Curl::GlobalInit();

auto deferred_cleanup = fit::defer([]{ Curl::GlobalCleanup(); });

// do something else and maybe spawn some threads

auto curl = fxl::MakeRefCounted

<Curl

>();

// curl->......

}

Public Methods

Error SetURL (const std::string & url)

Defined at line 78 of file ../../src/developer/debug/zxdb/common/curl.h

const std::string & post_data ()

Defined at line 82 of file ../../src/developer/debug/zxdb/common/curl.h

void set_post_data (const std::string & data)

Defined at line 83 of file ../../src/developer/debug/zxdb/common/curl.h

std::vector<std::string> & headers ()

Defined at line 86 of file ../../src/developer/debug/zxdb/common/curl.h

bool & get_body ()

Defined at line 87 of file ../../src/developer/debug/zxdb/common/curl.h

void set_data_callback (DataCallback handler)

Defined at line 89 of file ../../src/developer/debug/zxdb/common/curl.h

void set_header_callback (DataCallback handler)

Defined at line 90 of file ../../src/developer/debug/zxdb/common/curl.h

std::string Escape (const std::string & input)

Escapes URL strings (converts all letters consider illegal in URLs to their %XX versions)

Defined at line 360 of file ../../src/developer/debug/zxdb/common/curl.cc

void GlobalInit ()

Must be called before any threads are spawned and creation of Curl object.

Defined at line 317 of file ../../src/developer/debug/zxdb/common/curl.cc

void GlobalCleanup ()

Need to be called after all threads are joined for resource cleanup.

Defined at line 324 of file ../../src/developer/debug/zxdb/common/curl.cc

void set_post_data (const std::map<std::string, std::string> & items)

Defined at line 344 of file ../../src/developer/debug/zxdb/common/curl.cc

Error Perform ()

Run the curl request synchronously.

Defined at line 425 of file ../../src/developer/debug/zxdb/common/curl.cc

void Perform (fit::callback<void (Curl *, Error)> cb)

Run the curl request asynchronously. Invoke the callback when done.

Defined at line 432 of file ../../src/developer/debug/zxdb/common/curl.cc

long ResponseCode ()

Get the response code from the request. Undefined if the request hasn't

run.

Defined at line 438 of file ../../src/developer/debug/zxdb/common/curl.cc

Records

Friends

class MakeRefCountedHelper
class RefCountedThreadSafe