curl-library
Re: binary data post form buffer
Date: Fri, 30 Nov 2001 16:24:55 +0100 (MET)
On Fri, 30 Nov 2001, Hanno L. Kranzhoff wrote:
> I'm using libcurl with c++ win32 to post binary data from client to
> server via http-post.
> Currently I'm using
> ---
> curl_formadd(&m_formpost, &m_lastptr, CURLFORM_COPYNAME, "data",
> CURLFORM_FILE, "data.dat", CURLFORM_END);
> ---
> to accomplish that.
> Is there a way to post in the same way (multipart/form-data with
> boundary) but without using a file as input ? I would like to use e.g
> char* or something similara s input.
>
> CURLFORM_PTRCONTENTS doesn't help, as data is sent urlencoded w/o
> boundaries.
CURLFORM_PTRCONTENTS should work. If you point to binary data, you should
also set CURLFORM_CONTENTSLENGTH to the size, as otherwise libcurl will
strlen() to find the size.
If you don't want to keep the data around until curl is done with it, you can
tell curl to copy the data instead by using CURLFORM_COPYCONTENTS. That too
appreciate the size being set. Since you copy the name, you probably want to
copy the contents as well.
curl_formadd() should always create rfc1867-compatible form posts. They imply
proper boundaries. If you can provide source code that shows a non-working
case, please do. We'll be interested in correcting all known bugs.
-- Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/Received on 2001-11-30