23 std::string urlp =
url_+post_method;
25 sprintf(srun,
"%d",
run);
27 CURL* han = curl_easy_init();
30 XCEPT_RAISE(
evf::Exception,
"could not create handle for curlPoster");
32 struct curl_slist *headers=
NULL;
36 headers = curl_slist_append(headers,
"Content-Type: text/plain");
42 headers = curl_slist_append(headers,
"Content-Type: text/plain");
43 method =
"stacktrace";
48 headers = curl_slist_append(headers,
"Content-Type: text/plain");
54 headers = curl_slist_append(headers,
"Content-Type: application/octet-stream");
56 headers = curl_slist_append(headers,
"Expect:");
62 headers = curl_slist_append(headers,
"Content-Type: application/xml");
67 char error[CURL_ERROR_SIZE];
69 curl_easy_setopt(han, CURLOPT_URL, urlp.c_str());
71 curl_easy_setopt(han, CURLOPT_NOSIGNAL,
"");
72 curl_easy_setopt(han, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_0);
74 curl_formadd(&post, &last,
75 CURLFORM_COPYNAME,
"name",
76 CURLFORM_COPYCONTENTS,
buf_->nodename, CURLFORM_END);
77 curl_formadd(&post, &last,
78 CURLFORM_COPYNAME,
"run",
79 CURLFORM_COPYCONTENTS, srun, CURLFORM_END);
80 int retval = curl_formadd(&post, &last,
81 CURLFORM_COPYNAME, method.c_str(),
82 CURLFORM_COPYCONTENTS, content,
83 CURLFORM_CONTENTSLENGTH, len,
84 CURLFORM_CONTENTHEADER, headers,
86 if(retval != 0)
std::cout <<
"Error in formadd " << retval << std::endl;
87 curl_easy_setopt(han, CURLOPT_HTTPPOST, post);
88 curl_easy_setopt(han, CURLOPT_ERRORBUFFER, error);
90 int success = curl_easy_perform(han);
92 curl_easy_cleanup(han);
93 curl_slist_free_all(headers);
97 std::ostringstream
msg;
98 msg <<
"could not post data to url " <<
url_ <<
" error #"
99 << success <<
" " <<
error;
void post(const unsigned char *, size_t, unsigned int, mode, const std::string &)