cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: AW: C API questions

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 4 Dec 2002 18:41:18 +0100 (MET)

On Wed, 4 Dec 2002, Robert Barsch - x:act Developer Team wrote:

> > > As far I understood the examples there is no possibility for
> > > streaming/using sockets
> >
> > I don't understand what you mean.
>
> you can't stream like with sockets - there I could send byte for byte - it
> just doesnt matter how big the file size is

If you wanna use curl_formadd() yes, then this is the only way.

For a normal posts you can provide the data to post using a callback, which
would make it "streamish".

> > > which (as far as I know) are restricted to 64k in pure C.
> >
> > They are not. You must be confusing C with something else! ;-)
>
> maybe :) - so I think I lack i bit of C knowledge in here - just give me a
> hint how to make such a huge buffer lets say for a 20mb xml attachment (as
> far I know you can only allocate max. 64k memory with malloc)

Nope. malloc() can allocate HEAPS of memory. I think you're confusing this
with how malloc() used to work on some lame old crap OS back in the old days
(I believe DOS and Windows 3 might've had some limits like that). Modern
operating systems don't have such limits.

> > > Guess CURLOPT_CUSTOMREQUEST wont work in this case anymore...
> >
> > To do what?
>
> the php client sends the self generated http post (see last posting) and
> sends it over CURLOPT_CUSTOMREQUEST - so I didn't have to change to much -
> lazy me :) There I don't have to watch the file size.

You sent the POST using CUSTOMREQUEST? Wow. That's an odd solution I must
say... :-)

> > 2. Since you have a pretty clear understanding and exact wishes
> > of what you
> > want to send away, why don't you just create a big pre-formatted buffer
> > that looks the way you want it and do a regular POST with it? Set
> > CURLOPT_POST and then provide all post-data with a normal read
> > callback.
>
> cause of the memory issue - to send the whole pre-formatted buffer is no
> problem :)

If you want to upload a file that is larger than your physical and virtual
memory, you can generate a formpost file on disk (properly formatted) and
then let your callback read from that file, and thus you can formpost
any-sized files.

Or fix curl's formpost support so that it can read and send data in a more
streaming way instead of building it all in memory before posting (which
really isn't an impossible task, just not done).

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET 
comprehensive development tool, built to increase your 
productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
Received on 2002-12-04