form:AddContent(name, content[, type, headers])
form:AddContent()
is used to append a section when building a multipart/formdata HTTP POST
(sometimes referred to as RFC 2388-style posts). Once you've added all the sections you want included,
pass the form handle as parameter to #CURLOPT_HTTPPOST
. See easy:SetOpt_HTTPPost for details.
You must call form:Free() after the form post has been done to free the resources.
Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header
with #CURLOPT_HTTPHEADER
as usual.
First, there are some basics you need to understand about multipart/formdata posts. Each part consists of
at least a NAME
and a CONTENTS
part. If the part is made for file upload, there are also a stored
CONTENT-TYPE
and a FILENAME
. Below, we'll discuss what options you use to get these properties
in the parts you want to add to your post.
The name
argument must be a string which provides the name of this part. The name is not allowed to contain
zero-valued bytes. The content
argument must contain the actual data to send. The optional argument
type
can be used to get the content-type for the part and the optional argument headers
can be used
to specify extra headers for the form POST section. This takes a table containing a list and appends the list
of headers to those libcurl automatically generates.