Re: Web Queries through GTK



On Fri, 2005-08-05 at 02:30, Bhatnagar Achindra wrote:
I need to make http: Get/Post queries through my GTK application, 

I'm using libcurl with great success.  I use it on Win32 and Linux with
no problems at all.  libcurl is much faster than the normal .Net methods
by a long shot.  By faster I'm mainly referring to the startup time and
not the transfer speed.

libcurl has lots of great examples, but just to give you an idea how
easy it is, here is a section of my code where I send some XML back to
the server using post.  The CurlWriteMemoryCallback receives the
response from the server and I just use the example from the libcurl
site so nothing special there.

struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
xml = "<some xml>"

curl_handle = curl_easy_init();
curl_formadd(&formpost, 
    &lastptr, 
    CURLFORM_COPYNAME, 
    "ae_xml", 
    CURLFORM_COPYCONTENTS, 
    xml, 
    CURLFORM_END);

curl_easy_setopt(curl_post, CURLOPT_HTTPPOST, formpost);
curl_easy_setopt(curl_post, CURLOPT_WRITEFUNCTION,   
    CurlWriteMemoryCallback);
curl_easy_setopt(curl_post, CURLOPT_URL, url);
curl_easy_setopt(curl_post, CURLOPT_FILE, (void *)data);
curl_easy_perform(curl_post);
curl_formfree(formpost);





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]