cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: easy API: curl_easy_perform() doesn't return after receiving all data

From: James Buchanan <software.au_at_gmail.com>
Date: Thu, 2 Nov 2006 01:36:28 +1100

On 11/1/06, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Wed, 1 Nov 2006, James Buchanan wrote:
>
> > I'm using libCURL to use a SOAP web service. Everything works fine, except
> > that when I receive my response, using curl_easy_perform(), even after I
> > have received all the response data the function doesn't return. I have to
> > hit CTRL+C to see the results.
>
> What libcurl version on what platform?

me_at_spartacus:~$ curl-config --version
libcurl 7.13.2

me_at_spartacus:~$ uname -a
Linux spartacus 2.6.8-3-686-smp #1 SMP Thu Sep 7 04:39:15 UTC 2006
i686 GNU/Linux

Specifically, Debian GNU/Linux "Sarge" 3.1r3

> What libcurl options do you set in your request? How does your
> request-headers look like and what response-headers do you
> get when you see the problem?

curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, TRUE);

curl_easy_setopt(curl_handle, CURLOPT_HEADER, TRUE); // necessary?
curl_easy_setopt(curl_handle,
   CURLOPT_URL, "http://api.google.com/search/beta2");
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, TRUE);
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
curl_easy_setopt(curl_handle, CURLOPT_POST, TRUE);
curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, postdata_fcn);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, recvdata_fcn);
curl_easy_setopt(curl_handle,
   CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_easy_setopt(curl_handle, CURLOPT_DEBUGFUNCTION, debug_fcn);

curl_slist *http_headers = NULL;
http_headers = curl_slist_append(http_headers, "Host: api.google.com");
// http_headers = curl_slist_append(http_headers, "Connection: Close");
http_headers = curl_slist_append(http_headers,
   "Content-Type: text/xml; charset=utf-8");

// The Content-Length is always correct
http_headers = curl_slist_append(http_headers, content_length.c_str());
http_headers = curl_slist_append(http_headers,
    "SOAPAction: urn:GoogleSearchAction");
        
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, http_headers);

> Doe the problem show up every time?

Yes.

> No, libcurl has fully functional chunked-encoding support. Can you show us a
> full stream of what you get back, and then especially the end of the chunked
> body repsponse? (If that is a lot of data, then preferably pasted somewhere
> and not included in a mail.)

http://www.nwo.com.au/dump.dat

Is the CURLOPT_DEBUGFUNCTION option supposed to dump the POST payload
more than once? Likewise the response XML data payload from the
server?

Thanks very much for your help.

-J
Received on 2006-11-01