]> granicus.if.org Git - curl/commitdiff
CURLOPT_*.3: added lots of small example sections
authorDaniel Stenberg <daniel@haxx.se>
Tue, 17 Mar 2015 07:03:46 +0000 (08:03 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 17 Mar 2015 07:03:46 +0000 (08:03 +0100)
docs/libcurl/opts/CURLOPT_COOKIE.3
docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.3
docs/libcurl/opts/CURLOPT_INFILESIZE.3
docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.3
docs/libcurl/opts/CURLOPT_READDATA.3
docs/libcurl/opts/CURLOPT_REFERER.3
docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.3
docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.3
docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.3
docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3
docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3

index 379296a7ea269b7d11258ef944007178585b93b1..df115c66bc7a07753f4b48a84cdd6fa96a203341 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -51,7 +51,16 @@ NULL, no cookies
 .SH PROTOCOLS
 HTTP
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  curl_easy_setopt(curl, CURLOPT_COOKIE, "tool=curl; fun=yes;");
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 If HTTP is enabled
 .SH RETURN VALUE
index 11bff65c6209fff4a24295960670b9f54d41dc19..51fd6b08ce05a9e9600fa135ff04bc3ea9179101 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -42,7 +42,17 @@ Only use this option if strictly necessary.
 .SH PROTOCOLS
 HTTP
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  /* we know the server is silly, ignore content-length */
+  curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 Added in 7.14.1
 .SH RETURN VALUE
index 129414c07744d913231bb5635b9faf6aedcda8ac..fd49e21a75e4e9d542ad02129488ed4d511a53e0 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -49,7 +49,20 @@ Unset
 .SH PROTOCOLS
 Many
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  long uploadsize = FILE_SIZE;
+
+  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/destination.tar.gz");
+
+  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+
+  curl_easy_setopt(curl, CURLOPT_INFILESIZE, uploadsize);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 SMTP support added in 7.23.0
 .SH RETURN VALUE
index 0aa5224527362429a623aa217a8804941d6af3c7..114676d0ef67926ebe056fa75f3eeecfe0eb1da9 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -50,7 +50,20 @@ Unset
 .SH PROTOCOLS
 Many
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_off_t uploadsize = FILE_SIZE;
+
+  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/destination.tar.gz");
+
+  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+
+  curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadsize);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 SMTP support added in 7.23.0
 .SH RETURN VALUE
index db666316e325e102acf1a78fb585b2dec6a45996..a67f41542baa314e6aaa83205920f66ded0158e4 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -42,7 +42,19 @@ By default, this is a FILE * to stdin.
 .SH PROTOCOLS
 This is used for all protocols when sending data.
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+struct MyData this;
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  /* pass pointer that gets passed in to the
+     CURLOPT_READFUNCTION callback */
+  curl_easy_setopt(curl, CURLOPT_READDATA, &this);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 This option was once known by the older name \fICURLOPT_INFILE\fP, the name
 \fICURLOPT_READDATA\fP was introduced in 7.9.7.
index d00019b0169ad99b26476024ec08f4b2ef265865..bcb162515c2bb21985721a6290306df04cdd30cc 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -37,7 +37,17 @@ NULL
 .SH PROTOCOLS
 HTTP
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  /* tell it where we found the link to this place */
+  curl_easy_setopt(curl, CURLOPT_REFERER, "http://example.com/aboutme.html");
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 If built with HTTP support
 .SH RETURN VALUE
index ca39a09ec01e706cc1f306fd779fb9633fd377ad..fbf2042864757e5b9a4df9be8210a5cdcd5501c6 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -66,7 +66,17 @@ also set to zero and cannot be overridden.
 .SH PROTOCOLS
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3, SMTPS etc.
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+
+  /* Set the default value: strict name check please */
+  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 If built TLS enabled.
 .SH RETURN VALUE
index f2bad746435793b28cd33d5e89329c11ba0863d4..81bb59397ac8cf38f3b9e9d4b5b52c49cfce8f40 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -62,7 +62,17 @@ By default, curl assumes a value of 1.
 .SH PROTOCOLS
 All TLS based protocols: HTTPS, FTPS, IMAPS, POP3, SMTPS etc.
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+
+  /* Set the default value: strict certificate check please */
+  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 If built TLS enabled.
 .SH RETURN VALUE
index daf3df4a2f04c1d8af7a55f64f1dbd6d82bda38c..5ddadd093494d4aed23912611b6f9b089f1cb9ae 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -38,7 +38,23 @@ disable keepalive probes
 .SH PROTOCOLS
 All
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  /* enable TCP keep-alive for this transfer */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+
+  /* keep-alive idle time to 120 seconds */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
+
+  /* interval time between keep-alive probes: 60 seconds */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 Added in 7.25.0
 .SH RETURN VALUE
index 1724824f26067853e99a78ba27f043bcc3c7c9d2..843f65057d29d2a284714d34519dc913133ef1a0 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -36,7 +36,23 @@ operating systems support this option.
 .SH PROTOCOLS
 All
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  /* enable TCP keep-alive for this transfer */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+
+  /* set keep-alive idle time to 120 seconds */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
+
+  /* interval time between keep-alive probes: 60 seconds */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 Added in 7.25.0
 .SH RETURN VALUE
index e4bcf7ff424e8f05f76c4f4d8e9c1e7480069ef8..ee4d53543f1b18a1d9a9d4c178167896c1f7df42 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -34,7 +34,23 @@ option. (Added in 7.25.0)
 .SH DEFAULT
 .SH PROTOCOLS
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+  /* enable TCP keep-alive for this transfer */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+
+  /* keep-alive idle time to 120 seconds */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
+
+  /* interval time between keep-alive probes: 60 seconds */
+  curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L);
+
+  curl_easy_perform(curl);
+}
+.fi
 .SH AVAILABILITY
 Always
 .SH RETURN VALUE