Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- extern "C" {
- #include <curl/curl.h>
- }
- int main() {
- CURL *curl_handle;
- CURLcode res;
- static const char *postthis="{\"size\":100000,\"query\":{\"range\":{\"snapshotTime\":{\"from\":\"2012-10-31T13:00:00\",\"to\":\"2012-10-31T14:00:00\"}}}}";
- curl_global_init(CURL_GLOBAL_ALL);
- curl_handle = curl_easy_init();
- if(curl_handle) {
- curl_easy_setopt(curl_handle, CURLOPT_URL, "http://localhost:9202/_all/_search");
- curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, postthis);
- curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis));
- // curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, stdout);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, stdout);
- res = curl_easy_perform(curl_handle);
- if(res != CURLE_OK)
- fprintf(stderr, "curl_easy_perform() failed: %s\n",
- curl_easy_strerror(res));
- curl_easy_cleanup(curl_handle);
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement