curl-library
Re: POSTing data using curl
Date: Mon, 3 Jul 2006 10:06:22 -0400 (EDT)
On Mon, 3 Jul 2006, Nimrod A. Abing wrote:
> On 7/2/06, Teresa Thomas <tere.ertw_at_gmail.com> wrote:
>> Hi,
>> I am a newbie to Unix and libcurl and need some help in using the library.
>> I
>> want to make an HTTP POST request with a header and content. The content is
>> a plain text file which contains XML data.
>>
there are two ways (that i know of) to get a file to the server via POST.
one is the way suggested by nimrod, using a multipart/formdata post, which
is just like filling out a form with a file upload box using your browser.
this gives you the ability to transfer other data besides the file, and
some additional data about the file itself, like its name and type.
the second way, is to use CURLOPT_POSTFIELDS for curl_easy_setopt, which
basically tells curl not to interpret what you are sending, and gives you
complete control over the post body. you will have to make sure your xml
file is encoded in the fashion that your webserver wants, and make sure
that you tell curl how long it is (after encoding) with
CURLOPT_POSTFIELDSIZE. you will have to provide the data as a buffer, not
a filename. you will also have to play with the headers to tell curl what
the content type is, so it can tell the server...
read docs here:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOSTFIELDS
allan
Received on 2006-07-03