examples: use present tense in comments
remove "will" and some other word fixes Closes #13003
This commit is contained in:
Родитель
6e494a2390
Коммит
f540e43b9d
|
@ -47,7 +47,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -44,7 +44,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -100,7 +100,7 @@ int main(int argc, char **argv)
|
|||
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 */
|
||||
|
|
|
@ -139,7 +139,7 @@ int main(void)
|
|||
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
|
||||
*/
|
||||
|
@ -155,19 +155,18 @@ int main(void)
|
|||
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);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* Use CURLOPT_CONNECT_TO to connect to "wrong" host name
|
||||
* Use CURLOPT_CONNECT_TO to connect to "wrong" hostname
|
||||
* </DESC>
|
||||
*/
|
||||
#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
|
||||
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");
|
||||
|
||||
|
@ -51,13 +51,13 @@ int main(void)
|
|||
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 */
|
||||
|
|
|
@ -107,10 +107,9 @@ main(void)
|
|||
}
|
||||
|
||||
/* 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; "
|
||||
|
|
|
@ -43,7 +43,7 @@ int main(void)
|
|||
|
||||
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)
|
||||
|
|
|
@ -138,8 +138,8 @@ static void mcode_or_die(const char *where, CURLMcode code)
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -228,9 +228,9 @@ static void timer_cb(GlobalInfo* g, int revents)
|
|||
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;
|
||||
|
@ -386,8 +386,8 @@ static void new_conn(char *url, GlobalInfo *g)
|
|||
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 */
|
||||
|
|
|
@ -364,8 +364,8 @@ static void new_conn(char *url, GlobalInfo *g)
|
|||
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 */
|
||||
|
|
|
@ -106,8 +106,8 @@ int main(void)
|
|||
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");
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ int main(int argc, char **argv)
|
|||
/* 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 */
|
||||
|
|
|
@ -47,10 +47,10 @@ int main(void)
|
|||
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();
|
||||
|
|
|
@ -46,10 +46,10 @@
|
|||
#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;
|
||||
|
@ -90,7 +90,7 @@ int main(void)
|
|||
/* 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 */
|
||||
|
|
|
@ -76,7 +76,7 @@ int main(void)
|
|||
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) {
|
||||
|
@ -111,7 +111,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -112,12 +112,10 @@ static int upload(CURL *curlhandle, const char *remotepath,
|
|||
/* 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);
|
||||
|
|
|
@ -66,7 +66,7 @@ int main(void)
|
|||
|
||||
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);
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
|||
|
||||
/* 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)
|
||||
|
|
|
@ -39,7 +39,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -323,8 +323,8 @@ static void new_conn(char *url, GlobalInfo *g)
|
|||
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 */
|
||||
|
|
|
@ -51,7 +51,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
|
|
@ -358,8 +358,8 @@ static void new_conn(char *url, GlobalInfo *g)
|
|||
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 */
|
||||
|
@ -454,8 +454,9 @@ int main(int argc, char **argv)
|
|||
|
||||
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);
|
||||
|
|
|
@ -104,7 +104,7 @@ int main(void)
|
|||
|
||||
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)
|
||||
|
|
|
@ -42,10 +42,10 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -33,7 +33,7 @@ int main(void)
|
|||
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 */
|
||||
|
@ -46,7 +46,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
#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
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@
|
|||
#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
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -58,7 +58,7 @@ int main(int argc, char **argv)
|
|||
|
||||
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 */
|
||||
|
|
|
@ -82,7 +82,7 @@ int main(int argc, char **argv)
|
|||
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 */
|
||||
|
|
|
@ -57,8 +57,8 @@ int main(void)
|
|||
/*
|
||||
* 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
|
||||
|
@ -66,7 +66,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
|
|
@ -99,7 +99,7 @@ int main(void)
|
|||
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
|
||||
|
|
|
@ -53,7 +53,7 @@ int main(void)
|
|||
/* 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");
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ int main(void)
|
|||
/* 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. */
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ int main(void)
|
|||
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");
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ int main(void)
|
|||
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");
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ int main(void)
|
|||
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 */
|
||||
|
|
|
@ -48,7 +48,7 @@ int main(void)
|
|||
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");
|
||||
|
@ -67,13 +67,13 @@ int main(void)
|
|||
|
||||
/* 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);
|
||||
|
|
|
@ -48,14 +48,14 @@ int main(void)
|
|||
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);
|
||||
|
||||
|
@ -73,7 +73,7 @@ int main(void)
|
|||
* 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);
|
||||
|
|
|
@ -38,8 +38,8 @@ int main(void)
|
|||
/* 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/");
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -60,7 +60,7 @@ int main(void)
|
|||
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");
|
||||
|
|
|
@ -133,7 +133,7 @@ int main(void)
|
|||
|
||||
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);
|
||||
|
|
|
@ -98,7 +98,7 @@ static void check_multi_info(void)
|
|||
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;
|
||||
|
@ -155,8 +155,7 @@ static int start_timeout(CURLM *multi, long timeout_ms, void *userp)
|
|||
}
|
||||
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;
|
||||
|
|
|
@ -60,7 +60,7 @@ int main(void)
|
|||
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");
|
||||
|
|
|
@ -49,7 +49,7 @@ int main(void)
|
|||
|
||||
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 */
|
||||
|
|
|
@ -108,7 +108,7 @@ static void check_multi_info(void)
|
|||
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;
|
||||
|
@ -165,8 +165,7 @@ static int start_timeout(CURLM *multi, long timeout_ms, void *userp)
|
|||
}
|
||||
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;
|
||||
|
|
|
@ -48,7 +48,7 @@ int main(void)
|
|||
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);
|
||||
|
@ -75,6 +75,6 @@ int main(void)
|
|||
}
|
||||
|
||||
fail:
|
||||
curl_url_cleanup(h); /* free url handle */
|
||||
curl_url_cleanup(h); /* free URL handle */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
@ -55,7 +55,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -53,7 +53,7 @@ int main(void)
|
|||
/* 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 */
|
||||
|
|
|
@ -47,7 +47,7 @@ int main(void)
|
|||
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 */
|
||||
|
|
|
@ -56,7 +56,7 @@ int main(void)
|
|||
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 */
|
||||
|
|
|
@ -47,7 +47,7 @@ int main(void)
|
|||
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 */
|
||||
|
|
|
@ -48,7 +48,7 @@ int main(void)
|
|||
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");
|
||||
|
||||
|
@ -66,13 +66,13 @@ int main(void)
|
|||
|
||||
/* 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);
|
||||
|
|
|
@ -48,14 +48,14 @@ int main(void)
|
|||
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
|
||||
|
@ -72,7 +72,7 @@ int main(void)
|
|||
* 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);
|
||||
|
|
|
@ -73,7 +73,7 @@ int main(void)
|
|||
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) {
|
||||
|
@ -141,7 +141,7 @@ int main(void)
|
|||
}
|
||||
#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)
|
||||
|
|
|
@ -63,7 +63,7 @@ int main(void)
|
|||
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);
|
||||
|
@ -83,11 +83,10 @@ int main(void)
|
|||
|
||||
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) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* 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>
|
||||
*/
|
||||
|
@ -93,7 +93,7 @@ int main(int argc, char *argv[])
|
|||
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)
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
|
|||
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)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* GET a range only of a HTTP resource
|
||||
* GET a range only of an HTTP resource
|
||||
* </DESC>
|
||||
*/
|
||||
#include <curl/curl.h>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
/* <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>
|
||||
*/
|
||||
|
@ -35,9 +35,9 @@ int main(void)
|
|||
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");
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
|||
|
||||
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)
|
||||
|
|
|
@ -100,8 +100,7 @@ int main(void)
|
|||
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) {
|
||||
|
|
|
@ -34,10 +34,10 @@
|
|||
#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 {
|
||||
|
|
|
@ -57,8 +57,8 @@ int main(void)
|
|||
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();
|
||||
|
@ -70,7 +70,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
|
|
@ -39,7 +39,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
|
|
@ -41,11 +41,10 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
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 !!
|
||||
|
@ -124,7 +124,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
|
|
@ -113,8 +113,8 @@ gboolean pulse_bar(gpointer data)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -115,8 +115,8 @@ int main(void)
|
|||
/* 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
|
||||
|
@ -147,7 +147,7 @@ int main(void)
|
|||
/* 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
|
||||
|
|
|
@ -68,7 +68,7 @@ int main(void)
|
|||
/* 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
|
||||
|
|
|
@ -101,8 +101,8 @@ int main(void)
|
|||
/* 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
|
||||
|
@ -135,7 +135,7 @@ int main(void)
|
|||
/* 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
|
||||
|
|
|
@ -86,8 +86,8 @@ int main(void)
|
|||
/* 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
|
||||
|
@ -150,7 +150,7 @@ int main(void)
|
|||
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
|
||||
|
|
|
@ -103,7 +103,7 @@ int main(void)
|
|||
/* 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
|
||||
|
|
|
@ -117,14 +117,14 @@ int main(void)
|
|||
|
||||
/* 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
|
||||
|
@ -146,7 +146,7 @@ int main(void)
|
|||
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);
|
||||
|
|
|
@ -105,10 +105,10 @@ int main(void)
|
|||
* 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);
|
||||
|
||||
|
@ -125,8 +125,8 @@ int main(void)
|
|||
* 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
|
||||
|
@ -148,7 +148,7 @@ int main(void)
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -68,7 +68,7 @@ int main(void)
|
|||
/* 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
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
* 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,
|
||||
|
@ -59,7 +59,7 @@
|
|||
* 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.
|
||||
|
@ -71,7 +71,7 @@
|
|||
* 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)
|
||||
|
@ -171,7 +171,7 @@ size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
|
|||
break;
|
||||
}
|
||||
}
|
||||
AutoSyncTime = 3; /* Computer clock will be adjusted */
|
||||
AutoSyncTime = 3; /* Computer clock is adjusted */
|
||||
}
|
||||
else {
|
||||
AutoSyncTime = 0; /* Error in sscanf() fields conversion */
|
||||
|
|
|
@ -53,7 +53,7 @@ int main(void)
|
|||
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)
|
||||
|
|
|
@ -199,8 +199,7 @@ int main(void)
|
|||
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");
|
||||
|
@ -209,7 +208,7 @@ int main(void)
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -54,7 +54,7 @@ int main(void)
|
|||
/* 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)
|
||||
|
|
|
@ -113,7 +113,7 @@ int main(void)
|
|||
|
||||
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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче