cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Large Post data.... buffering?

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Tue, 10 Aug 2004 15:20:06 +0200 (CEST)

On Tue, 10 Aug 2004, Alan Pinstein wrote:

> This worked quite well! I would like to share my approach and have you
> confirm that I am using buffering:
>
> 1) I set CURLOPT_READDATA to a FILE* to my file.
> 2) I set CURLOPT_POST to 1.
> 3) I set CURLOPT_POSTFIELDSIZE to the length of my file.

Another option would be to enforce chunked-encoding, but that would require
that the server understands it (HTTP 1.1) and will add a slight overhead on
the network traffic.

> 4) I close my FILE* after the transfer completes.
>
> This seems to work perfectly... could you just confirm the approach? It's
> not clear from the Docs that the FILE* read mechanism uses buffering.

I'm not sure what you mean with "buffering" here. This approach will make
libcurl load the data to upload from the given file. It will not (and cannot)
load the whole file at once. It will in fact load CURL_MAX_WRITE_SIZE bytes at
a time from the file into the internal buffer and upload it.

> Also, I would like to recommend that the docs be modified slightly to make
> it more clear how all of the POST options work together...

Thanks. Based on your input, I edited the description for CURLOPT_POST in the
curl_easy_setopt man page. Hopefully it'll be a bit clearer now.

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-08-10