22 size_t RecvCB(
void* buffer,
size_t size,
size_t nmemb,
void* userp) {
25 if (size * nmemb < 1) {
29 my_buffer->
data =
static_cast<char*
>(buffer);
31 return my_buffer->
data.size();
39 : server_url_(server_url +
"/notifications/publish") {}
44 const char* user_agent_string =
"cvmfs/" CVMFS_VERSION;
46 CURL* h_curl = curl_easy_init();
49 curl_easy_setopt(h_curl, CURLOPT_NOPROGRESS, 1L);
50 curl_easy_setopt(h_curl, CURLOPT_USERAGENT, user_agent_string);
51 curl_easy_setopt(h_curl, CURLOPT_MAXREDIRS, 50L);
52 curl_easy_setopt(h_curl, CURLOPT_CUSTOMREQUEST,
"POST");
62 curl_easy_setopt(h_curl, CURLOPT_URL,
server_url_.c_str());
63 curl_easy_setopt(h_curl, CURLOPT_POSTFIELDSIZE_LARGE,
64 static_cast<curl_off_t>(msg.length()));
65 curl_easy_setopt(h_curl, CURLOPT_POSTFIELDS, msg.c_str());
66 curl_easy_setopt(h_curl, CURLOPT_WRITEFUNCTION,
RecvCB);
67 curl_easy_setopt(h_curl, CURLOPT_WRITEDATA, &buffer);
69 CURLcode ret = curl_easy_perform(h_curl);
75 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,...)