7 #include <sys/socket.h>
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: text/plain");
55 method =
"legendaAux";
60 headers = curl_slist_append(headers,
"Content-Type: application/octet-stream");
62 headers = curl_slist_append(headers,
"Expect:");
68 headers = curl_slist_append(headers,
"Content-Type: application/xml");
73 char error[CURL_ERROR_SIZE];
75 curl_easy_setopt(han, CURLOPT_URL, urlp.c_str());
77 curl_easy_setopt(han, CURLOPT_NOSIGNAL,
"");
78 curl_easy_setopt(han, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_0);
80 curl_formadd(&post, &last,
81 CURLFORM_COPYNAME,
"name",
82 CURLFORM_COPYCONTENTS,
buf_->nodename, CURLFORM_END);
83 curl_formadd(&post, &last,
84 CURLFORM_COPYNAME,
"run",
85 CURLFORM_COPYCONTENTS, srun, CURLFORM_END);
86 int retval = curl_formadd(&post, &last,
87 CURLFORM_COPYNAME, method.c_str(),
89 CURLFORM_CONTENTSLENGTH, len,
90 CURLFORM_CONTENTHEADER, headers,
92 if(retval != 0)
std::cout <<
"Error in formadd " << retval << std::endl;
93 curl_easy_setopt(han, CURLOPT_HTTPPOST, post);
94 curl_easy_setopt(han, CURLOPT_ERRORBUFFER, error);
95 curl_easy_setopt(han, CURLOPT_TIMEOUT, 5);
96 curl_easy_setopt(han, CURLOPT_CONNECTTIMEOUT, 5);
98 int success = curl_easy_perform(han);
100 curl_easy_cleanup(han);
101 curl_slist_free_all(headers);
105 std::ostringstream
msg;
106 msg <<
"could not post data to url " <<
url_ <<
" error #"
107 << success <<
" " <<
error;
116 post((
unsigned char*)content,(
unsigned int)len,run,m,post_method);
122 post(content,len,run,
bin,post_method);
129 sprintf(ps,
"run=%d",run);
130 CURL* han = curl_easy_init();
135 char error[CURL_ERROR_SIZE];
138 curl_easy_setopt(han, CURLOPT_URL,
url_.c_str() );
139 curl_easy_setopt(han, CURLOPT_POSTFIELDS,ps );
140 curl_easy_setopt(han, CURLOPT_WRITEFUNCTION, &
write_data );
141 curl_easy_setopt(han, CURLOPT_WRITEDATA, &dummy );
142 curl_easy_setopt(han, CURLOPT_ERRORBUFFER, error );
143 curl_easy_setopt(han, CURLOPT_TIMEOUT, 5 );
144 curl_easy_setopt(han, CURLOPT_CONNECTTIMEOUT, 5 );
145 int success = curl_easy_perform(han);
147 curl_easy_cleanup(han);
149 std::cout <<
"curlposter failed check" << std::endl;
void postString(const char *, size_t, unsigned int, mode, const std::string &=standard_post_method_)
void postBinary(const unsigned char *, size_t, unsigned int, const std::string &=standard_post_method_)
static const std::string standard_post_method_
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *pointer)
void post(const unsigned char *, size_t, unsigned int, mode, const std::string &)