curl-library
Re: Large Post data.... buffering?
Date: Tue, 10 Aug 2004 08:28:16 -0400
> You can make a POST use the read callback, and then you'd provide the
> data to libcurl from the file when it wants it.
>
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.
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.
-----------
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...
- To perform a POST request, set CURLOPT_POST to non-zero.
- By default this is a application/x-www-form-urlencoded, which you can
override by setting your own Content-Type header.
- To post string data, use CURLOPT_POSTFIELDS.
- To post a file, use CURLOPT_READDATA and pass in a FILE*. Also set
the transfer size with CURLOPT_POSTFIELDSIZE or
CURLOPT_POSTFIELDSIZE_LARGE.
- To post binary data, use CURLOPT_POSTFIELDS and set the size of the
binary data with CURLOPT_POSTFIELDSIZE or CURLOPT_POSTFIELDSIZE_LARGE.
At least for me, instructions like that would have been very helpful in
understanding what curl needs to do a POST. I am not sure that the
above is perfectly correct as it's just my observations /
interpretation of the docs.
Thanks,
Alan
Received on 2004-08-10