cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: question on HTTP PUT with unknown data size

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 7 Nov 2002 16:30:52 +0100 (MET)

On Thu, 7 Nov 2002 RBramante_at_on.com wrote:

> Do you have some thoughts or overview of the best way this should be
> implemented or how it fits in to the current code? If you do not think it
> would take too long I might be able to get some time to try and get it into
> curl if it becomes an important enough issue for us.

The basic functionality could be made like this:

We consider a case where we automaticly enable this is if we do PUT without a
known size. We append the proper header to the request and...

When we read data using the callback (around lib/transfer.c:900), we should
save a little extra data *before* the buffer where we read the new data into
(and an extra two bytes afterwords for a CRLF to get appended). Given that we
only deal with 32bit length, we need 10 bytes saved.

When we know how much data we received, we prepend "[SIZE in hex] CRLF" to
the data buffer and then we send that whole buffer to the server.

Repeat.

When the 0 is read from the callback, indicating end of data, we create a
terminating zero-length chunk and sends away that.

Done.

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
Received on 2002-11-07