diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-01-11 23:51:49 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-01-22 18:04:37 +0300 |
commit | 23b1a0ab70f190dbbb33dabb18ec039c7d85d6b3 (patch) | |
tree | c86693607a9be05c53a44ce311d8f83638cbda03 /libcurl/tests/basic/driver.c | |
parent | ed9a6438ec4b50ee897ac01296034de84167f2fe (diff) |
Add implementation
Diffstat (limited to 'libcurl/tests/basic/driver.c')
-rw-r--r-- | libcurl/tests/basic/driver.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libcurl/tests/basic/driver.c b/libcurl/tests/basic/driver.c new file mode 100644 index 0000000..8e78ba9 --- /dev/null +++ b/libcurl/tests/basic/driver.c @@ -0,0 +1,48 @@ +/* file : tests/basic/driver.c + * copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC + * license : cURL License; see accompanying COPYING file + */ +#include <stdio.h> +#include <assert.h> + +#include <curl/curl.h> + +/* Usage: argv[0] <URL> + * + * Request the specified URL and print the response to stdout. + */ +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + const char* url = argv[1]; + + curl_global_init (CURL_GLOBAL_DEFAULT); + + int r = 1; + + CURL* curl = curl_easy_init (); + + if (curl != NULL) + { + curl_easy_setopt (curl, CURLOPT_URL, url); + + CURLcode cr = curl_easy_perform (curl); + + if (cr == CURLE_OK) + r = 0; + else + fprintf (stderr, + "failed to request '%s': %s\n", + url, + curl_easy_strerror (cr)); + + curl_easy_cleanup (curl); + } + else + fprintf (stderr, "curl_easy_init() failed\n"); + + curl_global_cleanup (); + return r; +} |