cURL / Mailing Lists / curl-library / Single Mail

curl-library

Help on Linux 64 bit

From: Lai, Andy <hlai_at_informatica.com>
Date: Wed, 9 Mar 2005 19:18:30 -0800

Hi,

 

I have downloaded lib curl 7.12.2 and built it on Linux 64 bit platform.
I use curl to send an HTTP request to a servlet running on tomcat5. The
doPost() method is called, but no data can be read from the input stream
and timed out. Magically, curl received the error messages generated by
my servlet. Apparently curl did not send the request for some reason. I
have not debugged curl but I'd like to check if anyone encountered this
problem before...

 

My linux version:

Linux raiders 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:53:57 EST 2004 x86_64
x86_64 x86_64 GNU/Linux

 

The following is snippet showing how I make sure curl call. It works on
windows, solaris, and HPUX.

 

size_t request_callback(void *ptr, size_t size, size_t nmemb, void
*userp)

{

    // copy from my own memory to the ptr

}

 

    ///////////////////////////////////////////////////////////////////

    // Start CURL calls

    ///////////////////////////////////////////////////////////////////

    /* First set the URL that is about to receive our POST. */

    curl_easy_setopt(m_curl, CURLOPT_URL, url);

 

    /* Now specify we want to POST data */

    curl_easy_setopt(m_curl, CURLOPT_POST, TRUE);

 

    /* we want to use our own read function */

    curl_easy_setopt(m_curl, CURLOPT_READFUNCTION, request_callback);

 

    /* pointer to pass to our read function */

    curl_easy_setopt(m_curl, CURLOPT_READDATA, &req_buf);

 

    /* we want to use our own read function */

    curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, response_callback);

 

    /* we pass our 'chunk' struct to the callback function */

    curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &m_responseBuf);

 

    /* get verbose debug output please */

    curl_easy_setopt(m_curl, CURLOPT_VERBOSE, 0);

 

    /* Set the expected POST size. If you want to POST large amounts of
data,

       consider CURLOPT_POSTFIELDSIZE_LARGE */

    curl_easy_setopt(m_curl, CURLOPT_POSTFIELDSIZE, bufSize);

 

    /* Set the http headers */

    curl_slist *headers = NULL;

    headers = curl_slist_append(headers, "Content-Type: text/xml");

    curl_easy_setopt(m_curl, CURLOPT_HTTPHEADER, headers);

 

    /* Perform the request, res will get the return code */

    CURLcode res = curl_easy_perform(m_curl);

 

    curl_slist_free_all(headers);

 

Thanks,

Andy
Received on 2005-03-10