cURL / Mailing Lists / curl-library / Single Mail

curl-library

HTTP POST from memory. Again...

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

Here is the source of the form I want to POST to:
<HTML>
<BODY>
<FORM ACTION="client" METHOD="POST" ENCTYPE="multipart/form-data">
GLN
<INPUT TYPE="text" NAME="a_name">
<BR>
MsgType
<INPUT TYPE="file" NAME="another_name">
<BR>
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>

Here is the working HTTP POST from FILE*:

typedef struct errormsg{
        int message_number;
        char message_description[100];
}ERRORMSG;

ERRORMSG HttpPostFileOracle(char *URL, char *filename){
        ERRORMSG msg;
        CURL *curl=NULL;
        int res=0;
        FILE *response=NULL;
        FILE *file=NULL;
        char parse_buffer[100];

        int hd;
        struct _stat file_info;
        hd =_open(filename, _O_RDONLY) ;
    _fstat(hd, &file_info);
        _close(hd);

        response = fopen("\\response_dump.html", "w");
        if(response==NULL){
                msg.message_number=1;
                strcpy(msg.message_description,"FOPEN_FAILED");
                return msg;
        }
        file = fopen(filename, "r");
        if(file==NULL){
                msg.message_number=1;
                strcpy(msg.message_description,"FOPEN_FAILED");
                fclose(response);
                return msg;
        }
        
        struct HttpPost *post=NULL;
        struct HttpPost *last=NULL;
        
        curl = curl_easy_init();
        if(curl==NULL){
                msg.message_number=3;
                strcpy(msg.message_description,"CURL_EASY_INIT_FAILED");
                curl_easy_cleanup(curl);
                fclose(response);
                fclose(file);
                return msg;
        }
        res=0;
        strcpy(parse_buffer,"another_name=@");
        strcat(parse_buffer,filename);
        res=res||curl_formparse(parse_buffer, &post, &last);
        res=res||curl_formparse("a_name=", &post, &last);
        if(res!=0){
                msg.message_number=2;
                strcpy(msg.message_description,"CURL_FORMPARSE_FAILED");
                curl_easy_cleanup(curl);
                fclose(response);
                fclose(file);
                return msg;
        }
        res=res||curl_easy_setopt(curl, CURLOPT_URL, URL);
        res=res||curl_easy_setopt(curl, CURLOPT_HTTPPOST,post);
        res=res||curl_easy_setopt(curl, CURLOPT_FILE, response);
        if(res!=0){
                msg.message_number=4;
                strcpy(msg.message_description,"CURL_EASY_SETOPT_FAILED");
                curl_easy_cleanup(curl);
                fclose(response);
                fclose(file);
                return msg;
        }

        msg.message_number=0;
        strcpy(msg.message_description,"OK");
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        return msg;
}
This code is working using cURL 7.9 binaryes downloaded from
http://202.39.253.175/Jeff/curl/curl_7.9_devel.zip

I wish to replace the data source.
I want to make the POST from a buffer with call_back function.
It would realy help me because in call_back I want to make another
processing task with the data to be POSTed.

Is cURL working from VC++ with MFC?
I've tryed the cURL 7.9.8, which I've compiled, and I can't get it
linked in my app. Here are some errors:

nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
nafxcwd.lib(olelink.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(dcmeta.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype
nafxcwd.lib(oledlgs1.obj) : error LNK2001: unresolved external symbol __mbctype

Thank you in advance

__________________________________________________
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