cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 12 Nov 2006 20:45:22 +0100 (CET)

On Mon, 13 Nov 2006, James Buchanan wrote:

> Are you saying that after libcurl has called its CURLOPT_xxxFUNCTION and
> gets the data it POSTs to the server, it will correctly set Content-Length
> by itself?

Yes, if you use POSTFIELDS or when uploading set the INFILESIZE.

> If yes, in what order should I set things with curl_easy_setopt()?

Order is not important when you use curl_easy_setopt(), unless you set the
same option multiple times.

>> > CURL info: Connected to api.google.com (216.239.37.104) port 80 (#0)
>> >
>> > CURL HTTP Header Out: POST /search/beta2 HTTP/1.1
>> > Host: api.google.com
>> > Accept: */*
>> > Content-Type: text/xml; charset=utf-8
>> > Content-Length: 829
>> > SOAPAction: urn:GoogleSearchAction
>>
>> As you can see, this is only the request-heders being sent. It should also
>> send 829 of request-body...
>
> But it has, as you can see above, or am I misunderstanding something?

That snippest shows the request headers but no body. The Content-Length
specifies the size of the body.

> The read function is actually what is called when data is sent from
> the server to the application, is that correct?

Nope. The read function is what libcurl calls in your function when data
should be read from your system to get sent to the remote server.

> And the write function is what is called when libcurl needs the POST data to
> send to the server

... the write function is then the function you provide that writes data to a
local entity (file, memory area or whatever).

> (and presumably somewhere sets content-length if I return the correct
> content length in the write function callback?

No, the Content-Length is a header and is sent in the request before any read
or write callback is called.

> A couple of further questions: on Win32,
> curl_global_init(CURL_GLOBAL_WIN32) or
> curl_global_init(CURL_GLOBAL_ALL)?

Well, what do you want it to init? I believe these options are documented.

> And could there be potential issues with the order in which things are set
> with curl_easy_setopt()?

None that I know of at least.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-11-12