my_scope_id = if_nametoindex("eth0");
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);
/* Check for errors */
if(res != CURLE_OK)
curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long)
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);
/* Check for errors */
if(res != CURLE_OK)
fp = fopen(file, "rb");
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);
/* get a curl handle */
curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L);
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
* build-time
*/
else
printf("*** transfer failed ***\n");
- /* use a fresh connection (optional)
- * this option seriously impacts performance of multiple transfers but
- * it is necessary order to demonstrate this example. recall that the
- * ssl ctx callback is only called _before_ an SSL connection is
- * established, therefore it will not affect existing verified SSL
- * connections already in the connection cache associated with this
- * handle. normally you would set the ssl ctx function before making
- * any transfers, and not use this option.
+ /* use a fresh connection (optional) this option seriously impacts
+ * performance of multiple transfers but it is necessary order to
+ * demonstrate this example. recall that the ssl ctx callback is only called
+ * _before_ an SSL connection is established, therefore it does not affect
+ * existing verified SSL connections already in the connection cache
+ * associated with this handle. normally you would set the ssl ctx function
+ * before making any transfers, and not use this option.
*/
curl_easy_setopt(ch, CURLOPT_FRESH_CONNECT, 1L);
- /* second try: retrieve page using cacerts' certificate -> will succeed
- * load the certificate by installing a function doing the necessary
+ /* second try: retrieve page using cacerts' certificate -> succeeds to load
+ * the certificate by installing a function doing the necessary
* "modifications" to the SSL CONTEXT just before link init
*/
curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, sslctx_function);
*
***************************************************************************/
/* <DESC>
- * Use CURLOPT_CONNECT_TO to connect to "wrong" host name
+ * Use CURLOPT_CONNECT_TO to connect to "wrong" hostname
* </DESC>
*/
#include <stdio.h>
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.
*/
- /* instead of curl.se:443, it will resolve and use example.com:443 but in
- other aspects work as if it still is curl.se */
+ /* instead of curl.se:443, it resolves and uses example.com:443 but in other
+ aspects work as if it still is curl.se */
struct curl_slist *host = curl_slist_append(NULL,
"curl.se:443:example.com:443");
curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/");
/* 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 */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
/* 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
- sends an unknown name in the Host: header field */
+ goes through but (most likely) causes a 404 or similar because it sends
+ an unknown name in the Host: header field */
res = curl_easy_perform(curl);
/* always cleanup */
}
/* 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
- modified, likely not what you intended. Starting in 7.43.0 any-domain
- cookies will not be exported either. For more information refer to the
- CURLOPT_COOKIELIST documentation.
+ specify a domain then the cookie is sent for any domain and is not
+ modified, likely not what you intended. For more information refer to
+ the CURLOPT_COOKIELIST documentation.
*/
snprintf(nline, sizeof(nline),
"Set-Cookie: OLD_PREF=3d141414bf4209321; "
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);
/* Check for errors */
if(res != CURLE_OK)
static void timer_cb(GlobalInfo* g, int revents);
-/* Update the timer after curl_multi library does it's thing. Curl will
- * inform us through this callback what it wants the new timeout to be,
+/* Update the timer after curl_multi library does its thing. Curl informs the
+ * application through this callback what it wants the new timeout to be,
* after it does some work. */
static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{
if(err == -1) {
/* 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
- * epoll buffer (i.e. the timer may have fired multiple times). The
- * event count is cleared after the first call so future events in the
- * epoll buffer will fail to read from the timer. */
+ * epoll buffer (i.e. the timer may have fired multiple times). The event
+ * count is cleared after the first call so future events in the epoll
+ * buffer fails to read from the timer. */
if(errno == EAGAIN) {
fprintf(MSG_OUT, "EAGAIN on tfd %d\n", g->tfd);
return;
rc = curl_multi_add_handle(g->multi, conn->easy);
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
- the necessary socket_action() call will be called by this app */
+ /* note that the add_handle() sets a timeout to trigger soon so that the
+ * necessary socket_action() call gets called by this app */
}
/* This gets called whenever data is received from the fifo */
rc = curl_multi_add_handle(g->multi, conn->easy);
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
- the necessary socket_action() call will be called by this app */
+ /* note that add_handle() sets a timeout to trigger soon so that the
+ necessary socket_action() gets called */
}
/* This gets called whenever data is received from the fifo */
curl = curl_easy_init();
if(curl) {
/*
- * Note that libcurl will internally think that you connect to the host
- * and port that you specify in the URL option.
+ * Note that libcurl internally thinks that you connect to the host and
+ * port that you specify in the URL option.
*/
curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
/* callback is called after data from the file have been transferred */
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);
/* put transfer data into callbacks */
FILE *ftpfile;
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 */
- /* 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 */
curl = curl_easy_init();
#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS
#define RENAME_FILE_TO "renamed-and-fine.txt"
-/* NOTE: if you want this example to work on Windows with libcurl as a
- DLL, you MUST also provide a read callback with CURLOPT_READFUNCTION.
- Failing to do so will give you a crash since a DLL may not use the
- variable's memory when passed in to it from an app like this. */
+/* NOTE: if you want this example to work on Windows with libcurl as a DLL,
+ you MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
+ do so might give you a crash since a DLL may not use the variable's memory
+ 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)
{
unsigned long nread;
/* get a FILE * of the same file */
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);
/* get a curl handle */
upload.readptr = 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);
/* Check for errors */
if(res != CURLE_OK) {
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(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);
/* Check for errors */
if(res != CURLE_OK)
/* determine the length of the file already written */
/*
- * With NOBODY and NOHEADER, libcurl will issue a SIZE
- * command, but the only way to retrieve the result is
- * to parse the returned Content-Length header. Thus,
- * getcontentlengthfunc(). We need discardfunc() above
- * because HEADER will dump the headers to stdout
- * without it.
+ * With NOBODY and NOHEADER, libcurl issues a SIZE command, but the only
+ * way to retrieve the result is to parse the returned Content-Length
+ * header. Thus, getcontentlengthfunc(). We need discardfunc() above
+ * because HEADER dumps the headers to stdout without it.
*/
curl_easy_setopt(curlhandle, CURLOPT_NOBODY, 1L);
curl_easy_setopt(curlhandle, CURLOPT_HEADER, 1L);
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 */
curl_global_init(CURL_GLOBAL_ALL);
/* 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);
/* Check for errors */
if(res != CURLE_OK)
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
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);
/* Check for errors */
if(res != CURLE_OK)
rc = curl_multi_add_handle(g->multi, conn->easy);
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
- the necessary socket_action() call will be called by this app */
+ /* note that add_handle() sets a timeout to trigger soon so that the
+ necessary socket_action() gets called */
}
/* This gets called by glib whenever data is received from the fifo */
/* this example just ignores the content */
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);
/* Check for errors */
if(res != CURLE_OK)
rc = curl_multi_add_handle(g->multi, conn->easy);
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
- the necessary socket_action() call will be called by this app */
+ /* note that the add_handle() sets a time-out to trigger soon so that
+ the necessary socket_action() gets called */
}
/* This gets called whenever data is received from the fifo */
event_base_dispatch(g.evbase);
- /* this, of course, will not get called since only way to stop this program
- is via ctrl-C, but it is here to show how cleanup /would/ be done. */
+ /* this, of course, does not get called since the only way to stop this
+ program is via ctrl-C, but it is here to show how cleanup /would/ be
+ done. */
clean_fifo(&g);
event_del(&g.timer_event);
event_base_free(g.evbase);
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);
/* Check for errors */
if(res != CURLE_OK)
curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*");
/* 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);
- /* Perform the request, res will get the return code */
+ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
CURL *curl;
CURLcode res;
- /* In windows, this will init the winsock stuff */
+ /* In windows, this inits the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */
/* Now specify the POST data */
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);
/* Check for errors */
if(res != CURLE_OK)
#include <curl/mprintf.h>
#ifndef CURLPIPE_MULTIPLEX
-/* This little trick will just make sure that we do not enable pipelining for
- libcurls old enough to not have this symbol. It is _not_ defined to zero in
- a recent libcurl header. */
+/* This little trick makes sure that we do not enable pipelining for libcurls
+ old enough to not have this symbol. It is _not_ defined to zero in a recent
+ libcurl header. */
#define CURLPIPE_MULTIPLEX 0
#endif
#include <curl/mprintf.h>
#ifndef CURLPIPE_MULTIPLEX
-/* This little trick will just make sure that we do not enable pipelining for
- libcurls old enough to not have this symbol. It is _not_ defined to zero in
- a recent libcurl header. */
+/* This little trick makes sure that we do not enable pipelining for libcurls
+ old enough to not have this symbol. It is _not_ defined to zero in a recent
+ libcurl header. */
#define CURLPIPE_MULTIPLEX 0
#endif
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
(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);
/* Check for errors */
if(res != CURLE_OK)
url = argv[1];
- /* In windows, this will init the winsock stuff */
+ /* In windows, this inits the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */
an example! */
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);
/* get a curl handle */
/*
* If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or
- * subjectAltName) fields, libcurl will refuse to connect. You can skip
- * this check, but this will make the connection less secure.
+ * subjectAltName) fields, libcurl refuses to connect. You can skip this
+ * check, but it makes the connection insecure.
*/
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
/* cache the CA cert bundle in memory for a week */
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);
/* Check for errors */
if(res != CURLE_OK)
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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");
/* In this case, we are using a callback function to specify the data. You
/* Force PLAIN authentication */
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,
"imap://imap.example.com/INBOX/;UID=1");
/* Set the COPY command specifying the message ID and destination 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
* imap-store.c for more information on deleting messages. */
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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_USERNAME, "user");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
- /* This will list the folders within the user's mailbox. If you want to
- * list the folders within a specific folder, for example the inbox, then
+ /* This lists the folders within the user's mailbox. If you want to list
+ * the folders within a specific folder, for example the inbox, then
* 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_USERNAME, "user");
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");
/* Tell the multi stack about our easy handle */
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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. */
curl_easy_setopt(curl, CURLOPT_URL,
"imaps://imap.example.com/INBOX/;UID=1");
/* If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or
- * subjectAltName) fields, libcurl will refuse to connect. You can skip
- * this check, but this will make the connection less secure. */
+ * subjectAltName) fields, libcurl refuses to connect. You can skip this
+ * check, but it makes the connection insecure. */
#ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#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
* transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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");
- /* In this example, we will start with a plain text connection, and upgrade
- * to Transport Layer Security (TLS) using the STARTTLS command. Be careful
- * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer
- * will continue anyway - see the security discussion in the libcurl
+ /* In this example, we start with a plain text connection, and upgrade to
+ * Transport Layer Security (TLS) using the STARTTLS command. Be careful
+ * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the
+ * transfer continues anyway - see the security discussion in the libcurl
* tutorial for more details. */
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
* for more information. */
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
* transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* Try to use a local port number between 20000-20009 */
curl_easy_setopt(curl, CURLOPT_LOCALPORT, 20000L);
/* 10 means number of attempts, which starts with the number set in
- CURLOPT_LOCALPORT. The lowe value set, the smaller the change it will
- work. */
+ CURLOPT_LOCALPORT. The lower value set, the smaller the chance it
+ works. */
curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 10L);
curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/");
while(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);
/* Check for errors */
if(res != CURLE_OK)
for(i = 0; i<HANDLECOUNT; i++)
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[FTP_HANDLE], CURLOPT_URL, "ftp://example.com");
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_DEBUGFUNCTION, my_trace);
case CURLMSG_DONE:
/* Do not use message data after calling curl_multi_remove_handle() and
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
curl_easy_cleanup." */
easy_handle = message->easy_handle;
}
else {
if(timeout_ms == 0)
- timeout_ms = 1; /* 0 means directly call socket_action, but we will do it
- in a bit */
+ timeout_ms = 1; /* 0 means call socket_action asap */
struct timeval tv;
tv.tv_sec = timeout_ms / 1000;
tv.tv_usec = (timeout_ms % 1000) * 1000;
for(i = 0; i<HANDLECOUNT; i++)
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[FTP_HANDLE], CURLOPT_URL, "ftp://example.com");
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/");
/* init a multi stack */
case CURLMSG_DONE:
/* Do not use message data after calling curl_multi_remove_handle() and
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
curl_easy_cleanup." */
easy_handle = message->easy_handle;
}
else {
if(timeout_ms == 0)
- timeout_ms = 1; /* 0 means directly call socket_action, but we will do it
- in a bit */
+ timeout_ms = 1; /* 0 means call socket_action asap */
uv_timer_start(&timeout, on_timeout, timeout_ms, 0);
}
return 0;
if(uc)
goto fail;
- /* extract host name from the parsed URL */
+ /* extract hostname from the parsed URL */
uc = curl_url_get(h, CURLUPART_HOST, &host, 0);
if(!uc) {
printf("Host name: %s\n", host);
}
fail:
- curl_url_cleanup(h); /* free url handle */
+ curl_url_cleanup(h); /* free URL handle */
return 0;
}
/* get the first document */
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);
/* Check for errors */
if(res != CURLE_OK)
connection */
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);
/* Check for errors */
if(res != CURLE_OK)
/* Force PLAIN authentication */
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");
/* Perform the retr */
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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");
/* Perform the list */
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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");
/* Tell the multi stack about our easy handle */
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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");
/* Perform the retr */
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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. */
curl_easy_setopt(curl, CURLOPT_URL, "pop3s://pop.example.com/1");
/* If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or
- * subjectAltName) fields, libcurl will refuse to connect. You can skip
- * this check, but this will make the connection less secure. */
+ * subjectAltName) fields, libcurl refuses to connect. You can skip this
+ * check, but it makes the connection insecure. */
#ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#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
* transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
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");
- /* In this example, we will start with a plain text connection, and upgrade
- * to Transport Layer Security (TLS) using the STLS command. Be careful of
+ /* In this example, we start with a plain text connection, and upgrade to
+ * Transport Layer Security (TLS) using the STLS command. Be careful of
* using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer
- * will continue anyway - see the security discussion in the libcurl
- * tutorial for more details. */
+ * continues anyway - see the security discussion in the libcurl tutorial
+ * for more details. */
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
/* If your server does not have a valid certificate, then you can disable
* for more information. */
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
* transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
wt.readptr = 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);
/* Check for errors */
if(res != CURLE_OK) {
}
#endif
- /* Perform the request, res will get the return code */
+ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
struct MemoryStruct chunk;
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 */
curl_global_init(CURL_GLOBAL_ALL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
- /* if we do not provide POSTFIELDSIZE, libcurl will strlen() by
- itself */
+ /* if we do not provide POSTFIELDSIZE, libcurl calls strlen() by itself */
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);
/* Check for errors */
if(res != CURLE_OK) {
*/
/*
- * 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.
*
* Warning: this example uses the deprecated form api. See "postit2.c"
* 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">
* 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">
* </form>
*/
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
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);
/* Check for errors */
if(res != CURLE_OK)
* HTTP Multipart formpost with file upload and two additional parts.
* </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.
*
- * 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">
* 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">
* </form>
*
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
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);
/* Check for errors */
if(res != CURLE_OK)
*
***************************************************************************/
/* <DESC>
- * GET a range only of a HTTP resource
+ * GET a range only of an HTTP resource
* </DESC>
*/
#include <curl/curl.h>
*
***************************************************************************/
/* <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.
* </DESC>
*/
CURLcode res = CURLE_OK;
/* Each single name resolve string should be written using the format
- HOST:PORT:ADDRESS where HOST is the name libcurl will try to resolve,
- PORT is the port number of the service where libcurl wants to connect to
- the HOST and ADDRESS is the numerical IP address
+ HOST:PORT:ADDRESS where HOST is the name libcurl tries to resolve, PORT
+ is the port number of the service where libcurl wants to connect to the
+ HOST and ADDRESS is the numerical IP address
*/
struct curl_slist *host = curl_slist_append(NULL,
"example.com:443:127.0.0.1");
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);
/* Check for errors */
if(res != CURLE_OK)
return 1;
}
- /* Extract the socket from the curl handle - we will need it for
- waiting. */
+ /* Extract the socket from the curl handle - we need it for waiting. */
res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
if(res != CURLE_OK) {
#undef DISABLE_SSH_AGENT
/*
- * This is an example showing how to get a single file from an SFTP server.
- * It delays the actual destination file creation until the first write
- * callback so that it will not create an empty file in case the remote file
- * does not exist or something else fails.
+ * This is an example showing how to get a single file from an SFTP server. It
+ * delays the actual destination file creation until the first write callback
+ * so that it does not create an empty file in case the remote file does not
+ * exist or something else fails.
*/
struct FtpFile {
curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
- /* Loop the transfer and cleanup the handle properly every lap. This will
- still reuse connections since the pool is in the shared object! */
+ /* Loop the transfer and cleanup the handle properly every lap. This still
+ reuses connections since the pool is in the shared object! */
for(i = 0; i < 3; i++) {
CURL *curl = curl_easy_init();
/* use the share object */
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);
/* Check for errors */
if(res != CURLE_OK)
/* example.com is redirected, so we tell libcurl to follow redirection */
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);
/* Check for errors */
if(res != CURLE_OK)
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
- /* if we do not provide POSTFIELDSIZE, libcurl will strlen() by
- itself */
+ /* if we do not provide POSTFIELDSIZE, libcurl calls strlen() by itself */
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);
/* Check for errors */
if(res != CURLE_OK)
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
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"
!! verify of the server certificate is not implemented here !!
/* disconnect if we cannot validate server's cert */
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);
/* Check for errors */
if(res != CURLE_OK)
gtk_progress_bar_pulse(GTK_PROGRESS_BAR (data));
gdk_threads_leave();
- /* Return true so the function will be called again;
- * returning false removes this timeout function.
+ /* Return true so the function is called again; returning false removes this
+ * timeout function.
*/
return TRUE;
}
/* Force PLAIN authentication */
curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=PLAIN");
- /* Note that this option is not strictly required, omitting it will result
- * in libcurl sending the MAIL FROM command with empty sender data. All
+ /* Note that this option is not strictly required, omitting it results in
+ * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed
* 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
/* Free the list of 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
* (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
/* Free the list of 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
* 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
/* This is the URL for your mailserver */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
- /* Note that this option is not strictly required, omitting it will result
- * in libcurl sending the MAIL FROM command with empty sender data. All
+ /* Note that this option is not strictly required, omitting it results in
+ * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed
* 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
/* Free the list of 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
* (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
/* This is the URL for your mailserver */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
- /* Note that this option is not strictly required, omitting it will result
- * in libcurl sending the MAIL FROM command with empty sender data. All
+ /* Note that this option is not strictly required, omitting it results in
+ * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed
* 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
curl_slist_free_all(recipients);
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
* (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
/* This is the URL for your mailserver */
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
* autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, they
/* If the site you are connecting to uses a different host name that what
* they have mentioned in their server certificate's commonName (or
- * subjectAltName) fields, libcurl will refuse to connect. You can skip
- * this check, but this will make the connection less secure. */
+ * subjectAltName) fields, libcurl refuses to connect. You can skip this
+ * check, but it makes the connection insecure. */
#ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
- /* Note that this option is not strictly required, omitting it will result
- * in libcurl sending the MAIL FROM command with empty sender data. All
+ /* Note that this option is not strictly required, omitting it results in
+ * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed
* 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
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
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
* transfer */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
* matches your server configuration. */
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mainserver.example.net:587");
- /* In this example, we will start with a plain text connection, and upgrade
- * to Transport Layer Security (TLS) using the STARTTLS command. Be careful
- * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the transfer
- * will continue anyway - see the security discussion in the libcurl
+ /* In this example, we start with a plain text connection, and upgrade to
+ * Transport Layer Security (TLS) using the STARTTLS command. Be careful
+ * of using CURLUSESSL_TRY here, because if TLS upgrade fails, the
+ * transfer continues anyway - see the security discussion in the libcurl
* tutorial for more details. */
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
* for more information. */
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
- /* Note that this option is not strictly required, omitting it will result
- * in libcurl sending the MAIL FROM command with empty sender data. All
+ /* Note that this option is not strictly required, omitting it results in
+ * libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed
* 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
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
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
* transfer.
*/
/* Free the list of 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
* 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
* using HTTP protocol which has no problem with firewall/proxy.
*
* 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,
* or at least provide an accurate time keeping.
* 3. Webserver HTTP header does not provide the milliseconds units,
* as Round-Trip delay time is not taken into consideration.
* Compensation of network, firewall/proxy delay cannot be simply divide
* 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.
* 6. Webserver data should not be cached by the proxy server. Some
* webserver provide Cache-Control to prevent caching.
* tf.nist.gov/timefreq/service/firewall.htm
*
* 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.
*
* Written by: Frank (contributed to libcurl)
break;
}
}
- AutoSyncTime = 3; /* Computer clock will be adjusted */
+ AutoSyncTime = 3; /* Computer clock is adjusted */
}
else {
AutoSyncTime = 0; /* Error in sscanf() fields conversion */
curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, PATH);
#endif
- /* Perform the request, res will get the return code */
+ /* Perform the request, res gets the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
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);
if(rv == CURLE_OK) {
printf("*** transfer succeeded ***\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
* "modifications" to the SSL CONTEXT just before link init
*/
/* pass the easy handle to the callback */
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);
/* Check for errors */
if(res != CURLE_OK)
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);
/* Check for errors */
if(res != CURLE_OK)