diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index a28ecb769..5dac0e779 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -162,6 +162,10 @@ int main(int argc, char **argv) /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/debug.c b/docs/examples/debug.c index 270b497af..3852bf2cc 100644 --- a/docs/examples/debug.c +++ b/docs/examples/debug.c @@ -132,6 +132,10 @@ int main(void) curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/"); res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/fileupload.c b/docs/examples/fileupload.c index 756367b6b..665eca0af 100644 --- a/docs/examples/fileupload.c +++ b/docs/examples/fileupload.c @@ -64,14 +64,21 @@ int main(void) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) { + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); - /* now extract transfer info */ - curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed_upload); - curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time); + } + else { + /* now extract transfer info */ + curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed_upload); + curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time); - fprintf(stderr, "Speed: %.3f bytes/sec during %.3f seconds\n", - speed_upload, total_time); + fprintf(stderr, "Speed: %.3f bytes/sec during %.3f seconds\n", + speed_upload, total_time); + } /* always cleanup */ curl_easy_cleanup(curl); } diff --git a/docs/examples/ftpgetresp.c b/docs/examples/ftpgetresp.c index 29290a31d..db96a3a13 100644 --- a/docs/examples/ftpgetresp.c +++ b/docs/examples/ftpgetresp.c @@ -60,6 +60,10 @@ int main(void) curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_response); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, respfile); res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/ftpupload.c b/docs/examples/ftpupload.c index 9928b9e81..e79f8d842 100644 --- a/docs/examples/ftpupload.c +++ b/docs/examples/ftpupload.c @@ -122,6 +122,10 @@ int main(void) /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* clean up the FTP commands list */ curl_slist_free_all (headerlist); diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index 22de628ca..80f2b343b 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -38,6 +38,10 @@ int main(void) /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/httpcustomheader.c b/docs/examples/httpcustomheader.c index 077df2164..5c013750f 100644 --- a/docs/examples/httpcustomheader.c +++ b/docs/examples/httpcustomheader.c @@ -38,10 +38,18 @@ int main(void) curl_easy_setopt(curl, CURLOPT_URL, "localhost"); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* redo request with our own custom Accept: */ res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/httpput.c b/docs/examples/httpput.c index f04618f96..fbbca9448 100644 --- a/docs/examples/httpput.c +++ b/docs/examples/httpput.c @@ -110,6 +110,10 @@ int main(int argc, char **argv) /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/https.c b/docs/examples/https.c index 984357e37..8bfd90cac 100644 --- a/docs/examples/https.c +++ b/docs/examples/https.c @@ -55,7 +55,12 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/persistant.c b/docs/examples/persistant.c index 2d57e4907..0917dfdb8 100644 --- a/docs/examples/persistant.c +++ b/docs/examples/persistant.c @@ -37,12 +37,24 @@ int main(void) /* get the first document */ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/"); + + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* get another document from the same server using the same connection */ curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/docs/"); + + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/pop3s.c b/docs/examples/pop3s.c index 4a2e8fdeb..44d7c80d0 100644 --- a/docs/examples/pop3s.c +++ b/docs/examples/pop3s.c @@ -59,7 +59,12 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/pop3slist.c b/docs/examples/pop3slist.c index 54cb28784..9d9668fa0 100644 --- a/docs/examples/pop3slist.c +++ b/docs/examples/pop3slist.c @@ -59,7 +59,12 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index adadaf803..9736d8854 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -120,6 +120,10 @@ int main(void) /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/postit2.c b/docs/examples/postit2.c index 63c248467..67dcc1330 100644 --- a/docs/examples/postit2.c +++ b/docs/examples/postit2.c @@ -83,7 +83,13 @@ int main(int argc, char *argv[]) /* only disable 100-continue header if explicitly requested */ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); + + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 55877f8b2..cb23b7ae3 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -30,7 +30,13 @@ int main(void) curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); + + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/simplepost.c b/docs/examples/simplepost.c index 3c8571919..8657771f4 100644 --- a/docs/examples/simplepost.c +++ b/docs/examples/simplepost.c @@ -39,7 +39,12 @@ int main(void) itself */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis)); + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/simplesmtp.c b/docs/examples/simplesmtp.c index 84429f5bf..df8516242 100644 --- a/docs/examples/simplesmtp.c +++ b/docs/examples/simplesmtp.c @@ -65,6 +65,10 @@ int main(void) /* send the message (including headers) */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* free the list of recipients */ curl_slist_free_all(recipients); diff --git a/docs/examples/simplessl.c b/docs/examples/simplessl.c index 46a378329..b77c276e4 100644 --- a/docs/examples/simplessl.c +++ b/docs/examples/simplessl.c @@ -118,7 +118,13 @@ int main(void) /* disconnect if we can't validate server's cert */ curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L); + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + break; /* we are done... */ } /* always cleanup */ diff --git a/docs/examples/smtp-tls.c b/docs/examples/smtp-tls.c index 8e2603fa4..3635c103f 100644 --- a/docs/examples/smtp-tls.c +++ b/docs/examples/smtp-tls.c @@ -139,6 +139,10 @@ int main(void) /* send the message (including headers) */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* free the list of recipients and clean up */ curl_slist_free_all(recipients);