curl / Mailing Lists / curl-library / Single Mail

curl-library

HTTP PUT Without Callbacks

From: corey kasten <coreykasten_at_gmail.com>
Date: Wed, 22 Feb 2017 12:21:34 -0800

Hi:

I have been using HTTP POST method, via CURLOPT_POSTFIELDS and
CURLOPT_POSTFIELDSIZE, which I like, since I can just specify the pointer
to the data that I have in memory and don't need to use callbacks or files
to provide the data.

Now, I'd like to additionally make use of HTTP PUT, via the CURLOPT_UPLOAD
flag, which, as far as I can tell, would require the use of
CURLOPT_READFUNCTION in order to supply the data from memory, and, given
that I can fill only up to size*nitems bytes, this means that my
read_callback needs to keep track of where it left off in my memory buffer
so that on subsequent calls it can pick up where it left off (unlike if I
was supplying a real file for which the file-oriented interface (i.e.
fread()) would take care of this for me, implicitly).

Questions:
Is there a way to control the number of bytes that the curl engine will
request when it calls my read_callback, which, if there were, I could
return all the data in one callback invocation allowing me to not have to
keep state of the offset?
Am I right that I would have to do things this way?
If so, does it work this way because of some inherent difference between
HTTP POST and HTTP PUT that allows the simpler interface for POST
(CURLOPT_POSTFIELDS + CURLOPT_POSTFIELDSIZE) than the PUT requiring a
read_callback?
If not, would you consider feature request to allow PUT to be supported by
the same type of interface with which POST is supported (in addition to the
current interface for PUT)?

Thanks
Corey

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-02-22