19 size_t RecvCB(
void *buffer,
size_t size,
size_t nmemb,
void *userp) {
22 if (size * nmemb < 1) {
26 my_buffer->
data =
static_cast<char *
>(buffer);
28 return my_buffer->
data.size();
36 : server_url_(server_url +
"/notifications/publish") { }
41 const char *user_agent_string =
"cvmfs/" CVMFS_VERSION;
43 CURL *h_curl = curl_easy_init();
46 curl_easy_setopt(h_curl, CURLOPT_NOPROGRESS, 1L);
47 curl_easy_setopt(h_curl, CURLOPT_USERAGENT, user_agent_string);
48 curl_easy_setopt(h_curl, CURLOPT_MAXREDIRS, 50L);
49 curl_easy_setopt(h_curl, CURLOPT_CUSTOMREQUEST,
"POST");
59 curl_easy_setopt(h_curl, CURLOPT_URL,
server_url_.c_str());
60 curl_easy_setopt(h_curl, CURLOPT_POSTFIELDSIZE_LARGE,
61 static_cast<curl_off_t>(msg.length()));
62 curl_easy_setopt(h_curl, CURLOPT_POSTFIELDS, msg.c_str());
63 curl_easy_setopt(h_curl, CURLOPT_WRITEFUNCTION,
RecvCB);
64 curl_easy_setopt(h_curl, CURLOPT_WRITEDATA, &buffer);
66 const CURLcode ret = curl_easy_perform(h_curl);
72 curl_easy_cleanup(h_curl);
const LogFacilities & kLogError
PublisherHTTP(const std::string &server_url)
virtual bool Publish(const std::string &msg, const std::string &topic)
size_t RecvCB(void *buffer, size_t size, size_t nmemb, void *userp)
static LogFacilities error
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)