examples: use present tense in comments

remove "will" and some other word fixes

Closes #13003
This commit is contained in:
Daniel Stenberg 2024-02-27 12:29:27 +01:00
parent 6e494a2390
commit f540e43b9d
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
81 changed files with 189 additions and 198 deletions

View File

@ -47,7 +47,7 @@ int main(void)
my_scope_id = if_nametoindex("eth0"); my_scope_id = if_nametoindex("eth0");
curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id); curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -44,7 +44,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long) curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long)
CURLALTSVC_H1|CURLALTSVC_H2|CURLALTSVC_H3); CURLALTSVC_H1|CURLALTSVC_H2|CURLALTSVC_H3);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -100,7 +100,7 @@ int main(int argc, char **argv)
fp = fopen(file, "rb"); fp = fopen(file, "rb");
fstat(FILENO(fp), &file_info); fstat(FILENO(fp), &file_info);
/* In windows, this will init the winsock stuff */ /* In windows, this inits the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */ /* get a curl handle */

View File

@ -139,7 +139,7 @@ int main(void)
curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
/* Turn off the default CA locations, otherwise libcurl will load CA /* Turn off the default CA locations, otherwise libcurl loads CA
* certificates from the locations that were detected/specified at * certificates from the locations that were detected/specified at
* build-time * build-time
*/ */
@ -155,19 +155,18 @@ int main(void)
else else
printf("*** transfer failed ***\n"); printf("*** transfer failed ***\n");
/* use a fresh connection (optional) /* use a fresh connection (optional) this option seriously impacts
* this option seriously impacts performance of multiple transfers but * performance of multiple transfers but it is necessary order to
* it is necessary order to demonstrate this example. recall that the * demonstrate this example. recall that the ssl ctx callback is only called
* ssl ctx callback is only called _before_ an SSL connection is * _before_ an SSL connection is established, therefore it does not affect
* established, therefore it will not affect existing verified SSL * existing verified SSL connections already in the connection cache
* connections already in the connection cache associated with this * associated with this handle. normally you would set the ssl ctx function
* handle. normally you would set the ssl ctx function before making * before making any transfers, and not use this option.
* any transfers, and not use this option.
*/ */
curl_easy_setopt(ch, CURLOPT_FRESH_CONNECT, 1L); curl_easy_setopt(ch, CURLOPT_FRESH_CONNECT, 1L);
/* second try: retrieve page using cacerts' certificate -> will succeed /* second try: retrieve page using cacerts' certificate -> succeeds to load
* load the certificate by installing a function doing the necessary * the certificate by installing a function doing the necessary
* "modifications" to the SSL CONTEXT just before link init * "modifications" to the SSL CONTEXT just before link init
*/ */
curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, sslctx_function); curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, sslctx_function);

View File

@ -22,7 +22,7 @@
* *
***************************************************************************/ ***************************************************************************/
/* <DESC> /* <DESC>
* Use CURLOPT_CONNECT_TO to connect to "wrong" host name * Use CURLOPT_CONNECT_TO to connect to "wrong" hostname
* </DESC> * </DESC>
*/ */
#include <stdio.h> #include <stdio.h>
@ -39,8 +39,8 @@ int main(void)
request, PORT is the port of the request, CONNECT-TO-HOST is the host name request, PORT is the port of the request, CONNECT-TO-HOST is the host name
to connect to, and CONNECT-TO-PORT is the port to connect to. to connect to, and CONNECT-TO-PORT is the port to connect to.
*/ */
/* instead of curl.se:443, it will resolve and use example.com:443 but in /* instead of curl.se:443, it resolves and uses example.com:443 but in other
other aspects work as if it still is curl.se */ aspects work as if it still is curl.se */
struct curl_slist *host = curl_slist_append(NULL, struct curl_slist *host = curl_slist_append(NULL,
"curl.se:443:example.com:443"); "curl.se:443:example.com:443");
@ -51,13 +51,13 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/");
/* since this connects to the wrong host, checking the host name in the /* since this connects to the wrong host, checking the host name in the
server certificate will fail, so unless we disable the check libcurl server certificate fails, so unless we disable the check libcurl
returns CURLE_PEER_FAILED_VERIFICATION */ returns CURLE_PEER_FAILED_VERIFICATION */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
/* Letting the wrong host name in the certificate be okay, the transfer /* Letting the wrong host name in the certificate be okay, the transfer
goes through but will (most likely) cause a 404 or similar because it goes through but (most likely) causes a 404 or similar because it sends
sends an unknown name in the Host: header field */ an unknown name in the Host: header field */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* always cleanup */ /* always cleanup */

View File

@ -107,10 +107,9 @@ main(void)
} }
/* HTTP-header style cookie. If you use the Set-Cookie format and do not /* HTTP-header style cookie. If you use the Set-Cookie format and do not
specify a domain then the cookie is sent for any domain and will not be specify a domain then the cookie is sent for any domain and is not
modified, likely not what you intended. Starting in 7.43.0 any-domain modified, likely not what you intended. For more information refer to
cookies will not be exported either. For more information refer to the the CURLOPT_COOKIELIST documentation.
CURLOPT_COOKIELIST documentation.
*/ */
snprintf(nline, sizeof(nline), snprintf(nline, sizeof(nline),
"Set-Cookie: OLD_PREF=3d141414bf4209321; " "Set-Cookie: OLD_PREF=3d141414bf4209321; "

View File

@ -43,7 +43,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -138,8 +138,8 @@ static void mcode_or_die(const char *where, CURLMcode code)
static void timer_cb(GlobalInfo* g, int revents); static void timer_cb(GlobalInfo* g, int revents);
/* Update the timer after curl_multi library does it's thing. Curl will /* Update the timer after curl_multi library does its thing. Curl informs the
* inform us through this callback what it wants the new timeout to be, * application through this callback what it wants the new timeout to be,
* after it does some work. */ * after it does some work. */
static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g) static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{ {
@ -228,9 +228,9 @@ static void timer_cb(GlobalInfo* g, int revents)
if(err == -1) { if(err == -1) {
/* Note that we may call the timer callback even if the timerfd is not /* Note that we may call the timer callback even if the timerfd is not
* readable. It's possible that there are multiple events stored in the * readable. It's possible that there are multiple events stored in the
* epoll buffer (i.e. the timer may have fired multiple times). The * epoll buffer (i.e. the timer may have fired multiple times). The event
* event count is cleared after the first call so future events in the * count is cleared after the first call so future events in the epoll
* epoll buffer will fail to read from the timer. */ * buffer fails to read from the timer. */
if(errno == EAGAIN) { if(errno == EAGAIN) {
fprintf(MSG_OUT, "EAGAIN on tfd %d\n", g->tfd); fprintf(MSG_OUT, "EAGAIN on tfd %d\n", g->tfd);
return; return;
@ -386,8 +386,8 @@ static void new_conn(char *url, GlobalInfo *g)
rc = curl_multi_add_handle(g->multi, conn->easy); rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger soon so that /* note that the add_handle() sets a timeout to trigger soon so that the
the necessary socket_action() call will be called by this app */ * necessary socket_action() call gets called by this app */
} }
/* This gets called whenever data is received from the fifo */ /* This gets called whenever data is received from the fifo */

View File

@ -364,8 +364,8 @@ static void new_conn(char *url, GlobalInfo *g)
rc = curl_multi_add_handle(g->multi, conn->easy); rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger soon so that /* note that add_handle() sets a timeout to trigger soon so that the
the necessary socket_action() call will be called by this app */ necessary socket_action() gets called */
} }
/* This gets called whenever data is received from the fifo */ /* This gets called whenever data is received from the fifo */

View File

@ -106,8 +106,8 @@ int main(void)
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if(curl) {
/* /*
* Note that libcurl will internally think that you connect to the host * Note that libcurl internally thinks that you connect to the host and
* and port that you specify in the URL option. * port that you specify in the URL option.
*/ */
curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");

View File

@ -70,7 +70,7 @@ int main(int argc, char **argv)
/* callback is called after data from the file have been transferred */ /* callback is called after data from the file have been transferred */
curl_easy_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded); curl_easy_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded);
/* this callback will write contents into files */ /* this callback writes contents into files */
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_it); curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_it);
/* put transfer data into callbacks */ /* put transfer data into callbacks */

View File

@ -47,10 +47,10 @@ int main(void)
FILE *ftpfile; FILE *ftpfile;
FILE *respfile; FILE *respfile;
/* local file name to store the file as */ /* local filename to store the file as */
ftpfile = fopen(FTPBODY, "wb"); /* b is binary, needed on win32 */ ftpfile = fopen(FTPBODY, "wb"); /* b is binary, needed on win32 */
/* local file name to store the FTP server's response lines in */ /* local filename to store the FTP server's response lines in */
respfile = fopen(FTPHEADERS, "wb"); /* b is binary, needed on win32 */ respfile = fopen(FTPHEADERS, "wb"); /* b is binary, needed on win32 */
curl = curl_easy_init(); curl = curl_easy_init();

View File

@ -46,10 +46,10 @@
#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS #define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS
#define RENAME_FILE_TO "renamed-and-fine.txt" #define RENAME_FILE_TO "renamed-and-fine.txt"
/* NOTE: if you want this example to work on Windows with libcurl as a /* NOTE: if you want this example to work on Windows with libcurl as a DLL,
DLL, you MUST also provide a read callback with CURLOPT_READFUNCTION. you MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
Failing to do so will give you a crash since a DLL may not use the do so might give you a crash since a DLL may not use the variable's memory
variable's memory when passed in to it from an app like this. */ when passed in to it from an app like this. */
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{ {
unsigned long nread; unsigned long nread;
@ -90,7 +90,7 @@ int main(void)
/* get a FILE * of the same file */ /* get a FILE * of the same file */
hd_src = fopen(LOCAL_FILE, "rb"); hd_src = fopen(LOCAL_FILE, "rb");
/* In windows, this will init the winsock stuff */ /* In windows, this inits the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */ /* get a curl handle */

View File

@ -76,7 +76,7 @@ int main(void)
upload.readptr = data; upload.readptr = data;
upload.sizeleft = strlen(data); upload.sizeleft = strlen(data);
/* In windows, this will init the winsock stuff */ /* In windows, this inits the winsock stuff */
res = curl_global_init(CURL_GLOBAL_DEFAULT); res = curl_global_init(CURL_GLOBAL_DEFAULT);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) { if(res != CURLE_OK) {
@ -111,7 +111,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)upload.sizeleft); (curl_off_t)upload.sizeleft);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -112,12 +112,10 @@ static int upload(CURL *curlhandle, const char *remotepath,
/* determine the length of the file already written */ /* determine the length of the file already written */
/* /*
* With NOBODY and NOHEADER, libcurl will issue a SIZE * With NOBODY and NOHEADER, libcurl issues a SIZE command, but the only
* command, but the only way to retrieve the result is * way to retrieve the result is to parse the returned Content-Length
* to parse the returned Content-Length header. Thus, * header. Thus, getcontentlengthfunc(). We need discardfunc() above
* getcontentlengthfunc(). We need discardfunc() above * because HEADER dumps the headers to stdout without it.
* because HEADER will dump the headers to stdout
* without it.
*/ */
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 1L); curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 1L);
curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L); curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L);

View File

@ -66,7 +66,7 @@ int main(void)
struct MemoryStruct chunk; struct MemoryStruct chunk;
chunk.memory = malloc(1); /* will be grown as needed by the realloc above */ chunk.memory = malloc(1); /* grown as needed by the realloc above */
chunk.size = 0; /* no data at this point */ chunk.size = 0; /* no data at this point */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);

View File

@ -41,7 +41,7 @@ int main(void)
/* example.com is redirected, figure out the redirection! */ /* example.com is redirected, figure out the redirection! */
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -39,7 +39,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer"); curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer");
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -323,8 +323,8 @@ static void new_conn(char *url, GlobalInfo *g)
rc = curl_multi_add_handle(g->multi, conn->easy); rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger soon so that /* note that add_handle() sets a timeout to trigger soon so that the
the necessary socket_action() call will be called by this app */ necessary socket_action() gets called */
} }
/* This gets called by glib whenever data is received from the fifo */ /* This gets called by glib whenever data is received from the fifo */

View File

@ -51,7 +51,7 @@ int main(void)
/* this example just ignores the content */ /* this example just ignores the content */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -358,8 +358,8 @@ static void new_conn(char *url, GlobalInfo *g)
rc = curl_multi_add_handle(g->multi, conn->easy); rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger soon so that /* note that the add_handle() sets a time-out to trigger soon so that
the necessary socket_action() call will be called by this app */ the necessary socket_action() gets called */
} }
/* This gets called whenever data is received from the fifo */ /* This gets called whenever data is received from the fifo */
@ -454,8 +454,9 @@ int main(int argc, char **argv)
event_base_dispatch(g.evbase); event_base_dispatch(g.evbase);
/* this, of course, will not get called since only way to stop this program /* this, of course, does not get called since the only way to stop this
is via ctrl-C, but it is here to show how cleanup /would/ be done. */ program is via ctrl-C, but it is here to show how cleanup /would/ be
done. */
clean_fifo(&g); clean_fifo(&g);
event_del(&g.timer_event); event_del(&g.timer_event);
event_base_free(g.evbase); event_base_free(g.evbase);

View File

@ -104,7 +104,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -42,10 +42,10 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*"); curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*");
/* if this operation fails, allow risking a memory leak and do quick exit /* if this operation fails, allow risking a memory leak and do quick exit
from libcurl as this will exit() anyway */ from libcurl as this exits anyway */
curl_easy_setopt(curl, CURLOPT_QUICK_EXIT, 1L); curl_easy_setopt(curl, CURLOPT_QUICK_EXIT, 1L);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -33,7 +33,7 @@ int main(void)
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
/* In windows, this will init the winsock stuff */ /* In windows, this inits the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */ /* get a curl handle */
@ -46,7 +46,7 @@ int main(void)
/* Now specify the POST data */ /* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl"); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -39,9 +39,9 @@
#include <curl/mprintf.h> #include <curl/mprintf.h>
#ifndef CURLPIPE_MULTIPLEX #ifndef CURLPIPE_MULTIPLEX
/* This little trick will just make sure that we do not enable pipelining for /* This little trick makes sure that we do not enable pipelining for libcurls
libcurls old enough to not have this symbol. It is _not_ defined to zero in old enough to not have this symbol. It is _not_ defined to zero in a recent
a recent libcurl header. */ libcurl header. */
#define CURLPIPE_MULTIPLEX 0 #define CURLPIPE_MULTIPLEX 0
#endif #endif

View File

@ -41,9 +41,9 @@
#include <curl/mprintf.h> #include <curl/mprintf.h>
#ifndef CURLPIPE_MULTIPLEX #ifndef CURLPIPE_MULTIPLEX
/* This little trick will just make sure that we do not enable pipelining for /* This little trick makes sure that we do not enable pipelining for libcurls
libcurls old enough to not have this symbol. It is _not_ defined to zero in old enough to not have this symbol. It is _not_ defined to zero in a recent
a recent libcurl header. */ libcurl header. */
#define CURLPIPE_MULTIPLEX 0 #define CURLPIPE_MULTIPLEX 0
#endif #endif

View File

@ -41,7 +41,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
(long)CURL_HTTP_VERSION_3); (long)CURL_HTTP_VERSION_3);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -58,7 +58,7 @@ int main(int argc, char **argv)
url = argv[1]; url = argv[1];
/* In windows, this will init the winsock stuff */ /* In windows, this inits the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */ /* get a curl handle */

View File

@ -82,7 +82,7 @@ int main(int argc, char **argv)
an example! */ an example! */
hd_src = fopen(file, "rb"); hd_src = fopen(file, "rb");
/* In windows, this will init the winsock stuff */ /* In windows, this inits the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */ /* get a curl handle */

View File

@ -57,8 +57,8 @@ int main(void)
/* /*
* If the site you are connecting to uses a different host name that what * If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or * they have mentioned in their server certificate's commonName (or
* subjectAltName) fields, libcurl will refuse to connect. You can skip * subjectAltName) fields, libcurl refuses to connect. You can skip this
* this check, but this will make the connection less secure. * check, but it makes the connection insecure.
*/ */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif #endif
@ -66,7 +66,7 @@ int main(void)
/* cache the CA cert bundle in memory for a week */ /* cache the CA cert bundle in memory for a week */
curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 604800L); curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 604800L);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -99,7 +99,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will create a new message in folder "Sent". */ /* This creates a new message in folder "Sent". */
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/Sent"); curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/Sent");
/* In this case, we are using a callback function to specify the data. You /* In this case, we are using a callback function to specify the data. You

View File

@ -53,7 +53,7 @@ int main(void)
/* Force PLAIN authentication */ /* Force PLAIN authentication */
curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN"); curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN");
/* This will fetch message 1 from the user's inbox */ /* This fetches message 1 from the user's inbox */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL,
"imap://imap.example.com/INBOX/;UID=1"); "imap://imap.example.com/INBOX/;UID=1");

View File

@ -53,7 +53,7 @@ int main(void)
/* Set the COPY command specifying the message ID and destination folder */ /* Set the COPY command specifying the message ID and destination folder */
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "COPY 1 FOLDER"); curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "COPY 1 FOLDER");
/* Note that to perform a move operation you will need to perform the copy, /* Note that to perform a move operation you need to perform the copy,
* then mark the original mail as Deleted and EXPUNGE or CLOSE. Please see * then mark the original mail as Deleted and EXPUNGE or CLOSE. Please see
* imap-store.c for more information on deleting messages. */ * imap-store.c for more information on deleting messages. */

View File

@ -47,7 +47,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will fetch message 1 from the user's inbox */ /* This fetches message 1 from the user's inbox */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL,
"imap://imap.example.com/INBOX/;UID=1"); "imap://imap.example.com/INBOX/;UID=1");

View File

@ -47,8 +47,8 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will list the folders within the user's mailbox. If you want to /* This lists the folders within the user's mailbox. If you want to list
* list the folders within a specific folder, for example the inbox, then * the folders within a specific folder, for example the inbox, then
* specify the folder as a path in the URL such as /INBOX */ * specify the folder as a path in the URL such as /INBOX */
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com"); curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");

View File

@ -56,7 +56,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will fetch message 1 from the user's inbox */ /* This fetches message 1 from the user's inbox */
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1"); curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
/* Tell the multi stack about our easy handle */ /* Tell the multi stack about our easy handle */

View File

@ -48,7 +48,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will fetch message 1 from the user's inbox. Note the use of /* This fetches message 1 from the user's inbox. Note the use of
* imaps:// rather than imap:// to request a SSL based connection. */ * imaps:// rather than imap:// to request a SSL based connection. */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL,
"imaps://imap.example.com/INBOX/;UID=1"); "imaps://imap.example.com/INBOX/;UID=1");
@ -67,13 +67,13 @@ int main(void)
/* If the site you are connecting to uses a different host name that what /* If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or * they have mentioned in their server certificate's commonName (or
* subjectAltName) fields, libcurl will refuse to connect. You can skip * subjectAltName) fields, libcurl refuses to connect. You can skip this
* this check, but this will make the connection less secure. */ * check, but it makes the connection insecure. */
#ifdef SKIP_HOSTNAME_VERIFICATION #ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif #endif
/* Since the traffic will be encrypted, it is useful to turn on debug /* Since the traffic is encrypted, it is useful to turn on debug
* information within libcurl to see what is happening during the * information within libcurl to see what is happening during the
* transfer */ * transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

View File

@ -48,14 +48,14 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will fetch message 1 from the user's inbox */ /* This fetches message 1 from the user's inbox */
curl_easy_setopt(curl, CURLOPT_URL, curl_easy_setopt(curl, CURLOPT_URL,
"imap://imap.example.com/INBOX/;UID=1"); "imap://imap.example.com/INBOX/;UID=1");
/* In this example, we will start with a plain text connection, and upgrade /* In this example, we start with a plain text connection, and upgrade to
* to Transport Layer Security (TLS) using the STARTTLS command. Be careful * Transport Layer Security (TLS) using the STARTTLS command. Be careful
* of using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the
* will continue anyway - see the security discussion in the libcurl * transfer continues anyway - see the security discussion in the libcurl
* tutorial for more details. */ * tutorial for more details. */
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
@ -73,7 +73,7 @@ int main(void)
* for more information. */ * for more information. */
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
/* Since the traffic will be encrypted, it is useful to turn on debug /* Since the traffic is encrypted, it is useful to turn on debug
* information within libcurl to see what is happening during the * information within libcurl to see what is happening during the
* transfer */ * transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

View File

@ -38,8 +38,8 @@ int main(void)
/* Try to use a local port number between 20000-20009 */ /* Try to use a local port number between 20000-20009 */
curl_easy_setopt(curl, CURLOPT_LOCALPORT, 20000L); curl_easy_setopt(curl, CURLOPT_LOCALPORT, 20000L);
/* 10 means number of attempts, which starts with the number set in /* 10 means number of attempts, which starts with the number set in
CURLOPT_LOCALPORT. The lowe value set, the smaller the change it will CURLOPT_LOCALPORT. The lower value set, the smaller the chance it
work. */ works. */
curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 10L); curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 10L);
curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/");

View File

@ -51,7 +51,7 @@ int main(void)
while(urls[i]) { while(urls[i]) {
curl_easy_setopt(curl, CURLOPT_URL, urls[i]); curl_easy_setopt(curl, CURLOPT_URL, urls[i]);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -60,7 +60,7 @@ int main(void)
for(i = 0; i<HANDLECOUNT; i++) for(i = 0; i<HANDLECOUNT; i++)
handles[i] = curl_easy_init(); handles[i] = curl_easy_init();
/* set the options (I left out a few, you will get the point anyway) */ /* set the options (I left out a few, you get the point anyway) */
curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "https://example.com"); curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "https://example.com");
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_URL, "ftp://example.com"); curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_URL, "ftp://example.com");

View File

@ -133,7 +133,7 @@ int main(void)
http_handle = curl_easy_init(); http_handle = curl_easy_init();
/* set the options (I left out a few, you will get the point anyway) */ /* set the options (I left out a few, you get the point anyway) */
curl_easy_setopt(http_handle, CURLOPT_URL, "https://www.example.com/"); curl_easy_setopt(http_handle, CURLOPT_URL, "https://www.example.com/");
curl_easy_setopt(http_handle, CURLOPT_DEBUGFUNCTION, my_trace); curl_easy_setopt(http_handle, CURLOPT_DEBUGFUNCTION, my_trace);

View File

@ -98,7 +98,7 @@ static void check_multi_info(void)
case CURLMSG_DONE: case CURLMSG_DONE:
/* Do not use message data after calling curl_multi_remove_handle() and /* Do not use message data after calling curl_multi_remove_handle() and
curl_easy_cleanup(). As per curl_multi_info_read() docs: curl_easy_cleanup(). As per curl_multi_info_read() docs:
"WARNING: The data the returned pointer points to will not survive "WARNING: The data the returned pointer points to does not survive
calling curl_multi_cleanup, curl_multi_remove_handle or calling curl_multi_cleanup, curl_multi_remove_handle or
curl_easy_cleanup." */ curl_easy_cleanup." */
easy_handle = message->easy_handle; easy_handle = message->easy_handle;
@ -155,8 +155,7 @@ static int start_timeout(CURLM *multi, long timeout_ms, void *userp)
} }
else { else {
if(timeout_ms == 0) if(timeout_ms == 0)
timeout_ms = 1; /* 0 means directly call socket_action, but we will do it timeout_ms = 1; /* 0 means call socket_action asap */
in a bit */
struct timeval tv; struct timeval tv;
tv.tv_sec = timeout_ms / 1000; tv.tv_sec = timeout_ms / 1000;
tv.tv_usec = (timeout_ms % 1000) * 1000; tv.tv_usec = (timeout_ms % 1000) * 1000;

View File

@ -60,7 +60,7 @@ int main(void)
for(i = 0; i<HANDLECOUNT; i++) for(i = 0; i<HANDLECOUNT; i++)
handles[i] = curl_easy_init(); handles[i] = curl_easy_init();
/* set the options (I left out a few, you will get the point anyway) */ /* set the options (I left out a few, you get the point anyway) */
curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "https://example.com"); curl_easy_setopt(handles[HTTP_HANDLE], CURLOPT_URL, "https://example.com");
curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_URL, "ftp://example.com"); curl_easy_setopt(handles[FTP_HANDLE], CURLOPT_URL, "ftp://example.com");

View File

@ -49,7 +49,7 @@ int main(void)
http_handle = curl_easy_init(); http_handle = curl_easy_init();
/* set the options (I left out a few, you will get the point anyway) */ /* set the options (I left out a few, you get the point anyway) */
curl_easy_setopt(http_handle, CURLOPT_URL, "https://www.example.com/"); curl_easy_setopt(http_handle, CURLOPT_URL, "https://www.example.com/");
/* init a multi stack */ /* init a multi stack */

View File

@ -108,7 +108,7 @@ static void check_multi_info(void)
case CURLMSG_DONE: case CURLMSG_DONE:
/* Do not use message data after calling curl_multi_remove_handle() and /* Do not use message data after calling curl_multi_remove_handle() and
curl_easy_cleanup(). As per curl_multi_info_read() docs: curl_easy_cleanup(). As per curl_multi_info_read() docs:
"WARNING: The data the returned pointer points to will not survive "WARNING: The data the returned pointer points to does not survive
calling curl_multi_cleanup, curl_multi_remove_handle or calling curl_multi_cleanup, curl_multi_remove_handle or
curl_easy_cleanup." */ curl_easy_cleanup." */
easy_handle = message->easy_handle; easy_handle = message->easy_handle;
@ -165,8 +165,7 @@ static int start_timeout(CURLM *multi, long timeout_ms, void *userp)
} }
else { else {
if(timeout_ms == 0) if(timeout_ms == 0)
timeout_ms = 1; /* 0 means directly call socket_action, but we will do it timeout_ms = 1; /* 0 means call socket_action asap */
in a bit */
uv_timer_start(&timeout, on_timeout, timeout_ms, 0); uv_timer_start(&timeout, on_timeout, timeout_ms, 0);
} }
return 0; return 0;

View File

@ -48,7 +48,7 @@ int main(void)
if(uc) if(uc)
goto fail; goto fail;
/* extract host name from the parsed URL */ /* extract hostname from the parsed URL */
uc = curl_url_get(h, CURLUPART_HOST, &host, 0); uc = curl_url_get(h, CURLUPART_HOST, &host, 0);
if(!uc) { if(!uc) {
printf("Host name: %s\n", host); printf("Host name: %s\n", host);
@ -75,6 +75,6 @@ int main(void)
} }
fail: fail:
curl_url_cleanup(h); /* free url handle */ curl_url_cleanup(h); /* free URL handle */
return 0; return 0;
} }

View File

@ -44,7 +44,7 @@ int main(void)
/* get the first document */ /* get the first document */
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)
@ -55,7 +55,7 @@ int main(void)
connection */ connection */
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/docs/"); curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/docs/");
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -53,7 +53,7 @@ int main(void)
/* Force PLAIN authentication */ /* Force PLAIN authentication */
curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN"); curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN");
/* This will retrieve message 1 from the user's mailbox */ /* This retrieves message 1 from the user's mailbox */
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1"); curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
/* Perform the retr */ /* Perform the retr */

View File

@ -47,7 +47,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will list every message of the given mailbox */ /* This lists every message of the given mailbox */
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com"); curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com");
/* Perform the list */ /* Perform the list */

View File

@ -56,7 +56,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will retrieve message 1 from the user's mailbox */ /* This retrieves message 1 from the user's mailbox */
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1"); curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
/* Tell the multi stack about our easy handle */ /* Tell the multi stack about our easy handle */

View File

@ -47,7 +47,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will retrieve message 1 from the user's mailbox */ /* This retrieves message 1 from the user's mailbox */
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1"); curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
/* Perform the retr */ /* Perform the retr */

View File

@ -48,7 +48,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will retrieve message 1 from the user's mailbox. Note the use of /* This retrieves message 1 from the user's mailbox. Note the use of
* pop3s:// rather than pop3:// to request a SSL based connection. */ * pop3s:// rather than pop3:// to request a SSL based connection. */
curl_easy_setopt(curl, CURLOPT_URL, "pop3s://pop.example.com/1"); curl_easy_setopt(curl, CURLOPT_URL, "pop3s://pop.example.com/1");
@ -66,13 +66,13 @@ int main(void)
/* If the site you are connecting to uses a different host name that what /* If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or * they have mentioned in their server certificate's commonName (or
* subjectAltName) fields, libcurl will refuse to connect. You can skip * subjectAltName) fields, libcurl refuses to connect. You can skip this
* this check, but this will make the connection less secure. */ * check, but it makes the connection insecure. */
#ifdef SKIP_HOSTNAME_VERIFICATION #ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif #endif
/* Since the traffic will be encrypted, it is useful to turn on debug /* Since the traffic is encrypted, it is useful to turn on debug
* information within libcurl to see what is happening during the * information within libcurl to see what is happening during the
* transfer */ * transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

View File

@ -48,14 +48,14 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
/* This will retrieve message 1 from the user's mailbox */ /* This retrieves message 1 from the user's mailbox */
curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1"); curl_easy_setopt(curl, CURLOPT_URL, "pop3://pop.example.com/1");
/* In this example, we will start with a plain text connection, and upgrade /* In this example, we start with a plain text connection, and upgrade to
* to Transport Layer Security (TLS) using the STLS command. Be careful of * Transport Layer Security (TLS) using the STLS command. Be careful of
* using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer * using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer
* will continue anyway - see the security discussion in the libcurl * continues anyway - see the security discussion in the libcurl tutorial
* tutorial for more details. */ * for more details. */
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
/* If your server does not have a valid certificate, then you can disable /* If your server does not have a valid certificate, then you can disable
@ -72,7 +72,7 @@ int main(void)
* for more information. */ * for more information. */
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
/* Since the traffic will be encrypted, it is useful to turn on debug /* Since the traffic is encrypted, it is useful to turn on debug
* information within libcurl to see what is happening during the * information within libcurl to see what is happening during the
* transfer */ * transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

View File

@ -73,7 +73,7 @@ int main(void)
wt.readptr = data; wt.readptr = data;
wt.sizeleft = strlen(data); wt.sizeleft = strlen(data);
/* In windows, this will init the winsock stuff */ /* In windows, this inits the winsock stuff */
res = curl_global_init(CURL_GLOBAL_DEFAULT); res = curl_global_init(CURL_GLOBAL_DEFAULT);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) { if(res != CURLE_OK) {
@ -141,7 +141,7 @@ int main(void)
} }
#endif #endif
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -63,7 +63,7 @@ int main(void)
struct MemoryStruct chunk; struct MemoryStruct chunk;
static const char *postthis = "Field=1&Field=2&Field=3"; static const char *postthis = "Field=1&Field=2&Field=3";
chunk.memory = malloc(1); /* will be grown as needed by realloc above */ chunk.memory = malloc(1); /* grown as needed by realloc above */
chunk.size = 0; /* no data at this point */ chunk.size = 0; /* no data at this point */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
@ -83,11 +83,10 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
/* if we do not provide POSTFIELDSIZE, libcurl will strlen() by /* if we do not provide POSTFIELDSIZE, libcurl calls strlen() by itself */
itself */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis)); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis));
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) { if(res != CURLE_OK) {

View File

@ -27,17 +27,17 @@
*/ */
/* /*
* Example code that uploads a file name 'foo' to a remote script that accepts * Example code that uploads a filename 'foo' to a remote script that accepts
* "HTML form based" (as described in RFC 1738) uploads using HTTP POST. * "HTML form based" (as described in RFC 1738) uploads using HTTP POST.
* *
* Warning: this example uses the deprecated form api. See "postit2.c" * Warning: this example uses the deprecated form api. See "postit2.c"
* for a similar example using the mime api. * for a similar example using the mime api.
* *
* The imaginary form we will fill in looks like: * The imaginary form we fill in looks like:
* *
* <form method="post" enctype="multipart/form-data" action="examplepost.cgi"> * <form method="post" enctype="multipart/form-data" action="examplepost.cgi">
* Enter file: <input type="file" name="sendfile" size="40"> * Enter file: <input type="file" name="sendfile" size="40">
* Enter file name: <input type="text" name="filename" size="30"> * Enter filename: <input type="text" name="filename" size="30">
* <input type="submit" value="send" name="submit"> * <input type="submit" value="send" name="submit">
* </form> * </form>
*/ */
@ -93,7 +93,7 @@ int main(int argc, char *argv[])
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -25,14 +25,14 @@
* HTTP Multipart formpost with file upload and two additional parts. * HTTP Multipart formpost with file upload and two additional parts.
* </DESC> * </DESC>
*/ */
/* Example code that uploads a file name 'foo' to a remote script that accepts /* Example code that uploads a filename 'foo' to a remote script that accepts
* "HTML form based" (as described in RFC 1738) uploads using HTTP POST. * "HTML form based" (as described in RFC 1738) uploads using HTTP POST.
* *
* The imaginary form we will fill in looks like: * The imaginary form we fill in looks like:
* *
* <form method="post" enctype="multipart/form-data" action="examplepost.cgi"> * <form method="post" enctype="multipart/form-data" action="examplepost.cgi">
* Enter file: <input type="file" name="sendfile" size="40"> * Enter file: <input type="file" name="sendfile" size="40">
* Enter file name: <input type="text" name="filename" size="30"> * Enter filename: <input type="text" name="filename" size="30">
* <input type="submit" value="send" name="submit"> * <input type="submit" value="send" name="submit">
* </form> * </form>
* *
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_MIMEPOST, form); curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -22,7 +22,7 @@
* *
***************************************************************************/ ***************************************************************************/
/* <DESC> /* <DESC>
* GET a range only of a HTTP resource * GET a range only of an HTTP resource
* </DESC> * </DESC>
*/ */
#include <curl/curl.h> #include <curl/curl.h>

View File

@ -22,7 +22,7 @@
* *
***************************************************************************/ ***************************************************************************/
/* <DESC> /* <DESC>
* Use CURLOPT_RESOLVE to feed custom IP addresses for given host name + port * Use CURLOPT_RESOLVE to feed custom IP addresses for given hostname + port
* number combinations. * number combinations.
* </DESC> * </DESC>
*/ */
@ -35,9 +35,9 @@ int main(void)
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
/* Each single name resolve string should be written using the format /* Each single name resolve string should be written using the format
HOST:PORT:ADDRESS where HOST is the name libcurl will try to resolve, HOST:PORT:ADDRESS where HOST is the name libcurl tries to resolve, PORT
PORT is the port number of the service where libcurl wants to connect to is the port number of the service where libcurl wants to connect to the
the HOST and ADDRESS is the numerical IP address HOST and ADDRESS is the numerical IP address
*/ */
struct curl_slist *host = curl_slist_append(NULL, struct curl_slist *host = curl_slist_append(NULL,
"example.com:443:127.0.0.1"); "example.com:443:127.0.0.1");

View File

@ -41,7 +41,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -100,8 +100,7 @@ int main(void)
return 1; return 1;
} }
/* Extract the socket from the curl handle - we will need it for /* Extract the socket from the curl handle - we need it for waiting. */
waiting. */
res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd); res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
if(res != CURLE_OK) { if(res != CURLE_OK) {

View File

@ -34,10 +34,10 @@
#undef DISABLE_SSH_AGENT #undef DISABLE_SSH_AGENT
/* /*
* This is an example showing how to get a single file from an SFTP server. * This is an example showing how to get a single file from an SFTP server. It
* It delays the actual destination file creation until the first write * delays the actual destination file creation until the first write callback
* callback so that it will not create an empty file in case the remote file * so that it does not create an empty file in case the remote file does not
* does not exist or something else fails. * exist or something else fails.
*/ */
struct FtpFile { struct FtpFile {

View File

@ -57,8 +57,8 @@ int main(void)
curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock); curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock); curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
/* Loop the transfer and cleanup the handle properly every lap. This will /* Loop the transfer and cleanup the handle properly every lap. This still
still reuse connections since the pool is in the shared object! */ reuses connections since the pool is in the shared object! */
for(i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
@ -70,7 +70,7 @@ int main(void)
/* use the share object */ /* use the share object */
curl_easy_setopt(curl, CURLOPT_SHARE, share); curl_easy_setopt(curl, CURLOPT_SHARE, share);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -39,7 +39,7 @@ int main(void)
/* example.com is redirected, so we tell libcurl to follow redirection */ /* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -41,11 +41,10 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
/* if we do not provide POSTFIELDSIZE, libcurl will strlen() by /* if we do not provide POSTFIELDSIZE, libcurl calls strlen() by itself */
itself */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis)); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis));
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -38,7 +38,7 @@
3.2. set pEngine to the name of the crypto engine you use 3.2. set pEngine to the name of the crypto engine you use
3.3. set pKeyName to the key identifier you want to use 3.3. set pKeyName to the key identifier you want to use
4. if you do not use a crypto engine: 4. if you do not use a crypto engine:
4.1. set pKeyName to the file name of your client key 4.1. set pKeyName to the filename of your client key
4.2. if the format of the key file is DER, set pKeyType to "DER" 4.2. if the format of the key file is DER, set pKeyType to "DER"
!! verify of the server certificate is not implemented here !! !! verify of the server certificate is not implemented here !!
@ -124,7 +124,7 @@ int main(void)
/* disconnect if we cannot validate server's cert */ /* disconnect if we cannot validate server's cert */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -113,8 +113,8 @@ gboolean pulse_bar(gpointer data)
gtk_progress_bar_pulse(GTK_PROGRESS_BAR (data)); gtk_progress_bar_pulse(GTK_PROGRESS_BAR (data));
gdk_threads_leave(); gdk_threads_leave();
/* Return true so the function will be called again; /* Return true so the function is called again; returning false removes this
* returning false removes this timeout function. * timeout function.
*/ */
return TRUE; return TRUE;
} }

View File

@ -115,8 +115,8 @@ int main(void)
/* Force PLAIN authentication */ /* Force PLAIN authentication */
curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN"); curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN");
/* Note that this option is not strictly required, omitting it will result /* Note that this option is not strictly required, omitting it results in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise,
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
@ -147,7 +147,7 @@ int main(void)
/* Free the list of recipients */ /* Free the list of recipients */
curl_slist_free_all(recipients); curl_slist_free_all(recipients);
/* curl will not send the QUIT command until you call cleanup, so you /* curl does not send the QUIT command until you call cleanup, so you
* should be able to reuse this connection for additional messages * should be able to reuse this connection for additional messages
* (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and
* calling curl_easy_perform() again. It may not be a good idea to keep * calling curl_easy_perform() again. It may not be a good idea to keep

View File

@ -68,7 +68,7 @@ int main(void)
/* Free the list of recipients */ /* Free the list of recipients */
curl_slist_free_all(recipients); curl_slist_free_all(recipients);
/* curl will not send the QUIT command until you call cleanup, so you /* curl does not send the QUIT command until you call cleanup, so you
* should be able to reuse this connection for additional requests. It may * should be able to reuse this connection for additional requests. It may
* not be a good idea to keep the connection open for a long time though * not be a good idea to keep the connection open for a long time though
* (more than a few minutes may result in the server timing out the * (more than a few minutes may result in the server timing out the

View File

@ -101,8 +101,8 @@ int main(void)
/* This is the URL for your mailserver */ /* This is the URL for your mailserver */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
/* Note that this option is not strictly required, omitting it will result /* Note that this option is not strictly required, omitting it results in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise,
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
@ -135,7 +135,7 @@ int main(void)
/* Free the list of recipients */ /* Free the list of recipients */
curl_slist_free_all(recipients); curl_slist_free_all(recipients);
/* curl will not send the QUIT command until you call cleanup, so you /* curl does not send the QUIT command until you call cleanup, so you
* should be able to reuse this connection for additional messages * should be able to reuse this connection for additional messages
* (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and
* calling curl_easy_perform() again. It may not be a good idea to keep * calling curl_easy_perform() again. It may not be a good idea to keep

View File

@ -86,8 +86,8 @@ int main(void)
/* This is the URL for your mailserver */ /* This is the URL for your mailserver */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
/* Note that this option is not strictly required, omitting it will result /* Note that this option is not strictly required, omitting it results in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise,
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
@ -150,7 +150,7 @@ int main(void)
curl_slist_free_all(recipients); curl_slist_free_all(recipients);
curl_slist_free_all(headers); curl_slist_free_all(headers);
/* curl will not send the QUIT command until you call cleanup, so you /* curl does not send the QUIT command until you call cleanup, so you
* should be able to reuse this connection for additional messages * should be able to reuse this connection for additional messages
* (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and * (setting CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and
* calling curl_easy_perform() again. It may not be a good idea to keep * calling curl_easy_perform() again. It may not be a good idea to keep

View File

@ -103,7 +103,7 @@ int main(void)
/* This is the URL for your mailserver */ /* This is the URL for your mailserver */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
/* Note that this option is not strictly required, omitting it will result in /* Note that this option is not strictly required, omitting it results in
* libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, they * to the address in the reverse-path which triggered them. Otherwise, they

View File

@ -117,14 +117,14 @@ int main(void)
/* If the site you are connecting to uses a different host name that what /* If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or * they have mentioned in their server certificate's commonName (or
* subjectAltName) fields, libcurl will refuse to connect. You can skip * subjectAltName) fields, libcurl refuses to connect. You can skip this
* this check, but this will make the connection less secure. */ * check, but it makes the connection insecure. */
#ifdef SKIP_HOSTNAME_VERIFICATION #ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif #endif
/* Note that this option is not strictly required, omitting it will result /* Note that this option is not strictly required, omitting it results in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise,
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
@ -146,7 +146,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx); curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* Since the traffic will be encrypted, it is useful to turn on debug /* Since the traffic is encrypted, it is useful to turn on debug
* information within libcurl to see what is happening during the * information within libcurl to see what is happening during the
* transfer */ * transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

View File

@ -105,10 +105,10 @@ int main(void)
* matches your server configuration. */ * matches your server configuration. */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mainserver.example.net:587"); curl_easy_setopt(curl, CURLOPT_URL, "smtp://mainserver.example.net:587");
/* In this example, we will start with a plain text connection, and upgrade /* In this example, we start with a plain text connection, and upgrade to
* to Transport Layer Security (TLS) using the STARTTLS command. Be careful * Transport Layer Security (TLS) using the STARTTLS command. Be careful
* of using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the
* will continue anyway - see the security discussion in the libcurl * transfer continues anyway - see the security discussion in the libcurl
* tutorial for more details. */ * tutorial for more details. */
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
@ -125,8 +125,8 @@ int main(void)
* for more information. */ * for more information. */
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem"); curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
/* Note that this option is not strictly required, omitting it will result /* Note that this option is not strictly required, omitting it results in
* in libcurl sending the MAIL FROM command with empty sender data. All * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed * autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, * to the address in the reverse-path which triggered them. Otherwise,
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more * they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
@ -148,7 +148,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx); curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* Since the traffic will be encrypted, it is useful to turn on debug /* Since the traffic is encrypted, it is useful to turn on debug
* information within libcurl to see what is happening during the * information within libcurl to see what is happening during the
* transfer. * transfer.
*/ */

View File

@ -68,7 +68,7 @@ int main(void)
/* Free the list of recipients */ /* Free the list of recipients */
curl_slist_free_all(recipients); curl_slist_free_all(recipients);
/* curl will not send the QUIT command until you call cleanup, so you /* curl does not send the QUIT command until you call cleanup, so you
* should be able to reuse this connection for additional requests. It may * should be able to reuse this connection for additional requests. It may
* not be a good idea to keep the connection open for a long time though * not be a good idea to keep the connection open for a long time though
* (more than a few minutes may result in the server timing out the * (more than a few minutes may result in the server timing out the

View File

@ -50,7 +50,7 @@
* using HTTP protocol which has no problem with firewall/proxy. * using HTTP protocol which has no problem with firewall/proxy.
* *
* For this software to work, you should take note of these items. * For this software to work, you should take note of these items.
* 1. Your firewall/proxy must allow your computer to surf internet. * 1. Your firewall/proxy must allow your computer to surf Internet.
* 2. Webserver system time must in sync with the NTP time server, * 2. Webserver system time must in sync with the NTP time server,
* or at least provide an accurate time keeping. * or at least provide an accurate time keeping.
* 3. Webserver HTTP header does not provide the milliseconds units, * 3. Webserver HTTP header does not provide the milliseconds units,
@ -59,7 +59,7 @@
* as Round-Trip delay time is not taken into consideration. * as Round-Trip delay time is not taken into consideration.
* Compensation of network, firewall/proxy delay cannot be simply divide * Compensation of network, firewall/proxy delay cannot be simply divide
* the Round-Trip delay time by half. * the Round-Trip delay time by half.
* 5. Win32 SetSystemTime() API will set your computer clock according to * 5. Win32 SetSystemTime() API sets your computer clock according to
* GMT/UTC time. Therefore your computer timezone must be properly set. * GMT/UTC time. Therefore your computer timezone must be properly set.
* 6. Webserver data should not be cached by the proxy server. Some * 6. Webserver data should not be cached by the proxy server. Some
* webserver provide Cache-Control to prevent caching. * webserver provide Cache-Control to prevent caching.
@ -71,7 +71,7 @@
* tf.nist.gov/timefreq/service/firewall.htm * tf.nist.gov/timefreq/service/firewall.htm
* *
* Usage: * Usage:
* This software will synchronise your computer clock only when you issue * This software synchronises your computer clock only when you issue
* it with --synctime. By default, it only display the webserver's clock. * it with --synctime. By default, it only display the webserver's clock.
* *
* Written by: Frank (contributed to libcurl) * Written by: Frank (contributed to libcurl)
@ -171,7 +171,7 @@ size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
break; break;
} }
} }
AutoSyncTime = 3; /* Computer clock will be adjusted */ AutoSyncTime = 3; /* Computer clock is adjusted */
} }
else { else {
AutoSyncTime = 0; /* Error in sscanf() fields conversion */ AutoSyncTime = 0; /* Error in sscanf() fields conversion */

View File

@ -53,7 +53,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, PATH); curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, PATH);
#endif #endif
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -199,8 +199,7 @@ int main(void)
curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
curl_easy_setopt(ch, CURLOPT_SSLKEYTYPE, "PEM"); curl_easy_setopt(ch, CURLOPT_SSLKEYTYPE, "PEM");
/* first try: retrieve page without user certificate and key -> will fail /* first try: retrieve page without user certificate and key -> fails */
*/
rv = curl_easy_perform(ch); rv = curl_easy_perform(ch);
if(rv == CURLE_OK) { if(rv == CURLE_OK) {
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
@ -209,7 +208,7 @@ int main(void)
printf("*** transfer failed ***\n"); printf("*** transfer failed ***\n");
} }
/* second try: retrieve page using user certificate and key -> will succeed /* second try: retrieve page using user certificate and key -> succeeds
* load the certificate and key by installing a function doing the necessary * load the certificate and key by installing a function doing the necessary
* "modifications" to the SSL CONTEXT just before link init * "modifications" to the SSL CONTEXT just before link init
*/ */

View File

@ -54,7 +54,7 @@ int main(void)
/* pass the easy handle to the callback */ /* pass the easy handle to the callback */
curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl);
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)

View File

@ -113,7 +113,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 2L); /* websocket style */ curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 2L); /* websocket style */
/* Perform the request, res will get the return code */ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Check for errors */ /* Check for errors */
if(res != CURLE_OK) if(res != CURLE_OK)