curl-library
Re: CURLFORM_BUFFER vs CURLFORM_PTR
Date: Thu, 31 Aug 2006 09:49:38 -0400
Armel Asselin wrote:
> ...
> Mohun: is it more clear?
Yes, thank you both. I had basically missed the distinction between
"name" and "filename".
I do think this man page might benefit from a bit of grouping, or
another way of clarifying which options go together.
A few related notes on curlform stuff:
1. It appears that "filename" attributes are silently converted to lower
case and basenamed. I.e. 'curl_formadd(CURLFORM_FILENAME, "/FOO/BAR")'
results in "bar" being sent to the server according to my network
analyzer. I took a quick look at RFCs 2388 and 2184 but didn't see this
as a requirement anywhere. Is it?
2. Some combinations are illegal yet not clearly shown so. For instance
I have a buffer which I want to send as a file upload part but I need to
free my copy before the transfer. Thus I want COPYCONTENTS (as opposed
to PTRCONTENTS) behavior. I tried this combo:
curl_formadd(&formpost, &lastpost,
CURLFORM_CONTENTTYPE, "application/text; charset=UTF-8",
CURLFORM_COPYNAME, partname,
CURLFORM_FILENAME, filename, // seems not allowed
CURLFORM_COPYCONTENTS, buf,
CURLFORM_CONTENTSLENGTH, bytelen(buf),
CURLFORM_END);
which resulted in an empty form. Taking away CURLFORM_FILENAME made it
work (as a non-file part). There seems to be no way to get COPY behavior
for a file part using a pre-existing buffer.
3. Speaking of COPY behavior, I *suspect* the contract is that when you
ask libcurl to copy contents for you they will be freed by
curl_formfree(). But this is nowhere stated explicitly, at least not in
the curl_formadd page.
I would be happy to try contributing a doc patch to improve this once I
understand it sufficiently.
Thanks,
MB
Received on 2006-08-31