cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Advanced API?

From: Sterling Hughes <sterling_at_designmultimedia.com>
Date: Tue, 16 Oct 2001 11:24:53 +0200 (CEST)

> > Are there any plans for that old advanced api?
>
> I ran a very informal poll back in Febrary and the responses I got basically
> all said "no, we're happy with the current interface".
>

    hehe :) ya know what they say, its not important till ya need it
    yourself :)

> I would personally like to see an "advanced" more low level API, but I have
> no illusions that I can pull this off by myself so until someone steps
> forward to participate on this, I am not exploring those possibilities.
>

    I'll also volunteer to help with sub-tasks, however, I'm not sure
    enough in the current cURL source to know exactly what needs to be
    done...

> > I'm coming into a situation now, where i want to use
> > "read-when-available" processing with curl (ie, curl_read(), with
> > similair semantics to fread()). I know that processing multiple requests
> > is pretty simple when you have threads (or just forking :), but in some
> > situations (ie from php) you can't do it this way, and you need away to
> > read the requests small bits at a time, etc.
>
> You'd also want to somehow make the actual file/socket descriptor available
> to the outside so that people could select() on several simultanoues
> connections.
>

    That would be cool -- no doubt :)

> > are there any plans for adding a stdio type of interface to cURL? (or is
> > the noise I'm making the sound of me volunteering :)
>
> I'd happily join a devloper group aiming to get such an interface working the
> moment there is one! We'd need to set some basic goals and start scetching on
> how the interface would/could look like.
>

    Sounds good, personally I'm for something like the following
    interface:

    CURL *cp;
    char buf[1024];
    size_t nbytes;

    cp = curl_init();
    curl_setopt(cp, CURLOPT_URL, "http://www.someurl.com");

    // curl_select(cp, read,...);

    curl_connect(cp);
    while (!curl_is_eof(cp)) {
        nbytes = curl_read(cp, buf, 1024);
        if (nbytes == -1) {
            fprintf(stderr, "AHHHHH there was a read error %s",
                    curl_error(cp));
            return -1;
        }

        puts(buf);
    }

    curl_close(cp);
    curl_free(cp);

> As a side-note, I don't think there currently exists any HTTP or FTP library
> that offers such an interface. The best HTTP library competitor (IMO) out
> there, is neon, and it uses callbacks in a similar manner that libcurl does.
> The upcoming apache http library (named serf) is planned to offer both kinds
> of interfaces ("push" and "pull") but serf is gonna rely on APR and is likely
> to be very apache-centric which I think is gonna make it less attractive as
> an alternative to most non-apache related projects.
>
>

    I'm not thinking of switching ;)

    -Sterling
Received on 2001-10-16