test() { CURL *curl; CURLcode res; struct curl_slist *slist_header = NULL; FILE *pFile_error = fopen(CURL_ERROR_FILE, "w+"); curl = curl_easy_init(); if(curl) { slist_header = curl_slist_append(slist_header, version_id.data()); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist_header); QString follow_location=QString("With follow location"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, follow_location.data()); curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout_connect); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &progress_percent) ; curl_easy_setopt(curl, CURLOPT_WRITEDATA, &recv_buf); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback); curl_easy_setopt(curl, CURLOPT_HEADERDATA, &header_buf); curl_easy_setopt(curl, CURLOPT_POST, TRUE); curl_easy_setopt(curl, CURLOPT_POSTFIELDS,zip_buf); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,zip_len); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_STDERR, pFile_error); int res = curl_easy_perform(curl); if (res == 0) { ....... } curl_easy_cleanup(curl); curl_slist_free_all(slist_header); fflush(pFile_error); fclose(pFile_error); } }
|
评论
发表评论