cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: question on HTTP PUT with unknown data size

From: <RBramante_at_on.com>
Date: Thu, 7 Nov 2002 12:07:48 -0500

At least for a temporary fix, I implemented the chunked-encoding as part of
my callback.

Now I automatically prepend/append the chunk encodings to the data buffers
I am sending. I manually add the "Transfer-Encoding: chunked" header via
CURLOPT_HTTPHEADER and viola, chunked encoded puts.

This could serve to be a temporary solution to anyone that needs this until
it can go into curl proper. If I get time I'll try to have a look at doing
that.

                                                                                                                                          
                      Daniel Stenberg
                      <daniel_at_haxx.se> To: libcurl Mailing list <curl-library_at_lists.sourceforge.net>
                      Sent by: cc:
                      curl-library-admin_at_lists.sour Subject: Re: question on HTTP PUT with unknown data size
                      ceforge.net
                                                                                                                                          
                                                                                                                                          
                      11/07/2002 10:30 AM
                      Please respond to
                      curl-library
                                                                                                                                          
                                                                                                                                          

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
-------------------------------------------------------
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