cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Using multi interface with redirects and SSL negotiation

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 5 Feb 2009 22:07:46 +0100 (CET)

On Thu, 5 Feb 2009, James Cheng wrote:

> The WRITEFUNCTION and HEADERFUNCTION callbacks are called automatically by
> curl when curl_multi_perform() called and when data is available.
>
> Instead, I want to be notified when something is readable, and call the
> callbacks myself.

That's not really doable. libcurl has lots of states and knowledge about the
stream coming in that it'll deal with accordingly. You need to call libcurl to
have it do its magic.

> I know that the select() approach does that. How does that interact with
> FOLLOWLOCATION and SSL negotiation? Won't the select() return based on
> reading/writing done by curl itself?

No. As the socket gets readable/writable your application finds out by using
select() and then you invoke libcurl. libcurl then sends or receives data
depending on what it wants to do and the state of the socket. libcurl's own
sends and receives will not trigger any "actions" for your app's select().

> Any recommendations on how I can get notified of read-ability of the final
> headers and body, and not any intermediate headers caused by redirects?

That's not really possible. Since select() will get notified when the socket
is readable, and only when the callback is called you know it was (at least
partially) data that arrived.

-- 
  / daniel.haxx.se
Received on 2009-02-05