Base code merged to SPIN 2.4
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_POSTFIELDS.3
index b410bf6..d559143 100644 (file)
@@ -35,6 +35,8 @@ way. For example, the web server may assume that this data is url-encoded.
 
 The data pointed to is NOT copied by the library: as a consequence, it must be
 preserved by the calling application until the associated transfer finishes.
+This behaviour can be changed (so libcurl does copy the data) by setting the
+\fICURLOPT_COPYPOSTFIELDS(3)\fP option.
 
 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
@@ -58,7 +60,22 @@ NULL
 .SH PROTOCOLS
 HTTP
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  const char *data = "data to send";
+
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  /* size of the POST data */
+  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
+
+  /* pass in a pointer to the data - libcurl will not copy */
+  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 Always
 .SH RETURN VALUE