Click here to Skip to main content
13,048,035 members (107,384 online)
Rate this:
Please Sign up or sign in to vote.
See more:
#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_WRITEFUNCTION,&http_callback);
        curl_easy_setopt(curl, CURLOPT_URL,"");
        res = curl_easy_perform(curl);
        if(res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n",
        else {
            cout<<"receive data:"<<endl<<g_buf<<endl;
    return 0;

it always return 400.
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
Posted 6-Nov-12 21:29pm
Richard MacCutchan 7-Nov-12 4:14am
What is the text of the request you are sending?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

thanks, but i had found out the answer .
change "curl_easy_setopt(curl,CURLOPT_CUSTOMREQUEST,"delete");"

thanks for you answer. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100