#include <stdio.h> #include <curl/curl.h> #include <sys/stat.h> #include <fcntl.h> #include <string> #include <iostream> using namespace std; string g_buf = ""; size_t http_callback(void *buffer, size_t size, size_t count, void *user_p) { g_buf += (char*)buffer; return size*count; } int main(void) { CURL *curl; CURLcode res; struct stat file_info; double speed_upload, total_time; FILE *fd; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl,CURLOPT_CUSTOMREQUEST,"delete"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,&http_callback); curl_easy_setopt(curl, CURLOPT_URL,"http://ucenter.local.ucloud.cn/api/aiotest/test"); curl_easy_setopt(curl,CURLOPT_POSTFIELDS,"username=huancong&password=doyou"); res = curl_easy_perform(curl); if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); } else { cout<<"receive data:"<<endl<<g_buf<<endl; } curl_easy_cleanup(curl); } return 0; }
<html> <head><title>400 Bad Request</title></head> <body bgcolor="white"> <center><h1>400 Bad Request</h1></center> <hr><center>nginx/1.2.4</center> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)