aboutsummaryrefslogtreecommitdiff
path: root/docs/libcurl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-05-06 23:38:39 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-05-06 23:38:39 +0200
commit271c63748ada2fa04a25481990e3d7a55d08bed0 (patch)
tree0674a35be61e5d303215ef2710bc9150ec5fc524 /docs/libcurl
parenta8e388dd1095d3ffa12fc75f2bec70f1f9b66c80 (diff)
opts: examples added to 8 more libcurl option man pages
Diffstat (limited to 'docs/libcurl')
-rw-r--r--docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.321
-rw-r--r--docs/libcurl/opts/CURLINFO_CONTENT_TYPE.321
-rw-r--r--docs/libcurl/opts/CURLINFO_COOKIELIST.330
-rw-r--r--docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.321
-rw-r--r--docs/libcurl/opts/CURLINFO_HEADER_SIZE.318
-rw-r--r--docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.329
-rw-r--r--docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.321
-rw-r--r--docs/libcurl/opts/CURLINFO_NUM_CONNECTS.319
8 files changed, 164 insertions, 16 deletions
diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3 b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3
index e40d5ea9e..39adfe797 100644
--- a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3
+++ b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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,24 @@ Pass a pointer to a double to receive the specified size of the upload. Since
.SH PROTOCOLS
All
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+ /* Perform the upload */
+ res = curl_easy_perform(curl);
+
+ if(!res) {
+ /* check the size */
+ double cl;
+ res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
+ if(!res) {
+ printf("Size: %.0f\n", cl);
+ }
+ }
+}
+.fi
.SH AVAILABILITY
Added in 7.6.1
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3 b/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3
index 7536000c4..a7cd70fe9 100644
--- a/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3
+++ b/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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
@@ -39,7 +39,24 @@ corresponding CURL handle.
.SH PROTOCOLS
HTTP(S)
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+ res = curl_easy_perform(curl);
+
+ if(!res) {
+ /* extract the content-type */
+ char *ct = NULL;
+ res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
+ if(!res && ct) {
+ printf("Content-Type: %s\n", ct);
+ }
+ }
+ curl_easy_cleanup(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.9.4
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLINFO_COOKIELIST.3 b/docs/libcurl/opts/CURLINFO_COOKIELIST.3
index b9f75f4db..18203dba7 100644
--- a/docs/libcurl/opts/CURLINFO_COOKIELIST.3
+++ b/docs/libcurl/opts/CURLINFO_COOKIELIST.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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
@@ -40,7 +40,33 @@ domain name are not exported by this option.
.SH PROTOCOLS
HTTP(S)
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+ /* enable the cookie engine with a non-existing file */
+ curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "-");
+
+ res = curl_easy_perform(curl);
+
+ if(!res) {
+ /* extract all known cookies */
+ struct curl_slist *cookies = NULL;
+ res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
+ if(!res && cookies) {
+ /* a linked list of cookies in cookie file format */
+ while(cookies) {
+ printf("%s", cookies->data);
+ cookies = cookies->next;
+ }
+ /* we must free these cookies when we're done */
+ curl_slist_free_all(cookies);
+ }
+ }
+ curl_easy_cleanup(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.14.1
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3 b/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3
index e7d7fcff2..716ff9fee 100644
--- a/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3
+++ b/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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
@@ -39,7 +39,24 @@ corresponding CURL handle.
.SH PROTOCOLS
FTP(S) and SFTP
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
+
+ res = curl_easy_perform(curl);
+
+ if(!res) {
+ /* extract the entry path */
+ char *ep = NULL;
+ res = curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &ep);
+ if(!res && ep) {
+ printf("Entry path was: %s\n", ep);
+ }
+ }
+ curl_easy_cleanup(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.15.4. Works for SFTP since 7.21.4
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLINFO_HEADER_SIZE.3 b/docs/libcurl/opts/CURLINFO_HEADER_SIZE.3
index b687c80b9..f7d9e7e54 100644
--- a/docs/libcurl/opts/CURLINFO_HEADER_SIZE.3
+++ b/docs/libcurl/opts/CURLINFO_HEADER_SIZE.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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,21 @@ The total includes the size of any received headers suppressed by
.SH PROTOCOLS
All
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ CURLcode res;
+ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+ res = curl_easy_perform(curl);
+ if(res == CURLE_OK) {
+ long size;
+ res = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &size);
+ if(!res)
+ printf("Header size: %ld bytes\n", size);
+ }
+ curl_easy_cleanup(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.4.1
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3 b/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3
index a5d0e725a..da6ee77fa 100644
--- a/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3
+++ b/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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
@@ -35,7 +35,32 @@ bits is explained in the \fICURLOPT_HTTPAUTH(3)\fP option for
.SH PROTOCOLS
HTTP(S)
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+
+ res = curl_easy_perform(curl);
+
+ if(!res) {
+ /* extract the content-type */
+ long auth;
+ res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_AVAIL, &auth);
+ if(!res) {
+ if(!auth)
+ printf("No auth available, perhaps no 401?\n");
+ else {
+ printf("%s%s%s%s\n",
+ auth & CURLAUTH_BASIC ? "Basic ":"",
+ auth & CURLAUTH_DIGEST ? "Digest ":"",
+ auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
+ auth % CURLAUTH_NTLM ? "NTLM ":"");
+ }
+ }
+ }
+ curl_easy_cleanup(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.10.8
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3 b/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3
index acfef77fe..4ecbcaaa7 100644
--- a/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3
+++ b/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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,24 @@ was available.
.SH PROTOCOLS
HTTP
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ CURLcode res;
+ curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
+
+ /* typically CONNECT is used to do HTTPS over HTTP proxies */
+ curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1");
+ res = curl_easy_perform(curl);
+ if(res == CURLE_OK) {
+ long code;
+ res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &code);
+ if(!res && code)
+ printf("The CONNECT response code: %03ld\n", code);
+ }
+ curl_easy_cleanup(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.10.7
.SH RETURN VALUE
diff --git a/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3 b/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3
index eccff500c..ae1ddae99 100644
--- a/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3
+++ b/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, 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,22 @@ to make persistent connections to save time.
.SH PROTOCOLS
All
.SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+ CURLcode res;
+ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+ res = curl_easy_perform(curl);
+ if(res == CURLE_OK) {
+ long connects;
+ res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
+ if(res)
+ printf("It needed %d connects\n", connects);
+ }
+ curl_easy_cleanup(curl);
+}
+.fi
.SH AVAILABILITY
Added in 7.12.3
.SH RETURN VALUE