cURL / Mailing Lists / curl-library / Single Mail

curl-library

(no subject)

From: SHIRETU <eqqpqouo_at_yahoo.com>
Date: Wed, 19 Jun 2002 04:22:42 -0700 (PDT)

Here is the POST from memory function and it isn't working:

BOOL CHttp::Post(CString URL, CString data)
{
        WriteThis pdata;
        pdata.readptr=data.GetBuffer(data.GetLength());
        pdata.sizeleft=data.GetLength();
        CURL *curl=NULL;
        int res=0;
        FILE *response=NULL;
        CString parse_buffer;
        struct HttpPost *post=NULL;
        struct HttpPost *last=NULL;
        
        response = fopen("c:\\andrei\\fisiere\\response_dump.html", "w");
        if(response==NULL)
                throw(0);
        
        curl = curl_easy_init();
        if(curl==NULL)
                throw(0);
        res=0;
        if(res!=0)
                throw(0);
        res=res||curl_easy_setopt(curl, CURLOPT_URL, URL.GetBuffer(URL.GetLength()));
        res=res||curl_easy_setopt(curl, CURLOPT_POST,1);
        res=res||curl_easy_setopt(curl, CURLOPT_POSTFIELDS,"a_name=1234567890123");
        res=res||curl_easy_setopt(curl, CURLOPT_FILE, response);
        res=res||curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
        res=res||curl_easy_setopt(curl, CURLOPT_INFILE,&pdata);
        res=res||curl_easy_setopt(curl, CURLOPT_INFILESIZE, data.GetLength());
        if(res!=0)
                throw(0);

        curl_easy_perform(curl);
        if(res!=0)
                throw(0);

        fclose(response);
        curl_easy_cleanup(curl);

        return TRUE;
}

I didn't bother to do error handling because it is temporaly code.

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

----------------------------------------------------------------------------
                   Bringing you mounds of caffeinated joy
>>> http://thinkgeek.com/sf <<<
Received on 2002-06-19