Name
easy:SetOpt_PostFields -- specify data to POST to server
Synopsis
easy:SetOpt_PostFields(postdata)
Function
Pass a string as parameter, pointing to the full data to send in an HTTP POST operation. You must make sure that the data is formatted the way you want the server to receive it. libcurl will not convert or encode it for you in any way. For example, the web server may assume that this data is url-encoded.

This POST is a normal application/x-www-form-urlencoded kind (and libcurl will set that Content-Type by default when this option is used), which is commonly used by HTML forms. Change Content-Type with #CURLOPT_HTTPHEADER.

You can use easy:Escape() to url-encode your data, if necessary. It returns an encoded string that can be passed as postdata.

Using #CURLOPT_POSTFIELDS implies setting #CURLOPT_POST to 1.

If #CURLOPT_POSTFIELDS is explicitly set to Nil then libcurl will get the POST data from the read callback. If you want to send a zero-byte POST set #CURLOPT_POSTFIELDS to an empty string, or set #CURLOPT_POST to 1 and #CURLOPT_POSTFIELDSIZE to 0.

Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header, and libcurl will add that header automatically if the POST is either known to be larger than 1024 bytes or if the expected size is unknown. You can disable this header with #CURLOPT_HTTPHEADER as usual.

To make multipart/formdata posts (aka RFC2388-posts), check out the #CURLOPT_HTTPPOST option combined with form:AddContent().

Inputs
postdata
input value

Show TOC