15 curl_global_init(CURL_GLOBAL_ALL);
16 const int cryptoNumLocks = CRYPTO_num_locks();
19 mutexes_ = (pthread_mutex_t*)malloc( cryptoNumLocks *
sizeof(pthread_mutex_t) );
23 for (
int i = 0;
i < cryptoNumLocks; ++
i)
33 CRYPTO_set_id_callback(0);
34 CRYPTO_set_locking_callback(0);
36 for (
int i = 0;
i < CRYPTO_num_locks(); ++
i)
41 curl_global_cleanup();
58 const std::string&
url,
59 const std::string&
user,
63 CURL* curl = curl_easy_init();
64 if ( ! curl )
return CURLE_FAILED_INIT;
66 curl_easy_setopt(curl, CURLOPT_USERPWD, user.c_str());
68 return do_curl(curl, url, content);
74 const std::string& url,
80 CURL* curl = curl_easy_init();
81 if ( ! curl )
return CURLE_FAILED_INIT;
83 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buf);
84 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, size);
86 struct curl_slist *headers=
NULL;
87 headers = curl_slist_append(headers,
"Content-Type: application/octet-stream");
88 headers = curl_slist_append(headers,
"Content-Transfer-Encoding: binary");
89 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
91 const CURLcode
status = do_curl(curl, url, content);
92 curl_slist_free_all(headers);
100 char errorBuffer[CURL_ERROR_SIZE];
102 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
103 curl_easy_setopt(curl, CURLOPT_TIMEOUT, 4);
104 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
106 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &content);
107 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
108 curl_easy_setopt(curl, CURLOPT_FAILONERROR,1);
110 const CURLcode
returnCode = curl_easy_perform(curl);
112 curl_easy_cleanup(curl);
114 if (returnCode != CURLE_OK)
118 while ( errorBuffer[i] !=
'\0' )
120 content.push_back( errorBuffer[i] );
123 content.push_back(
'\0');
132 if (buffer ==
NULL)
return 0;
134 const size_t length = size * nmemb;
135 buffer->insert(buffer->end(),
data, data+length);
142 if (mode & CRYPTO_LOCK)
151 return ( (
unsigned long)pthread_self() );
static void sslLockingFunction(int mode, int n, const char *file, int line)
static unsigned long sslIdFunction()
static boost::shared_ptr< CurlInterface > getInterface()
static boost::shared_ptr< CurlInterface > interface_
CURLcode do_curl(CURL *, const std::string &url, Content &content)
CURLcode getContent(const std::string &url, const std::string &user, Content &content)
boost::shared_ptr< CurlInterface > CurlInterfacePtr
static size_t writeToString(char *data, size_t size, size_t nmemb, Content *buffer)
static pthread_mutex_t * mutexes_
char data[epos_bytes_allocation]
CURLcode postBinaryMessage(const std::string &url, void *buf, size_t size, Content &content)
tuple size
Write out results.
std::vector< char > Content