summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-02-25 21:44:44 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-02-25 23:53:49 +0300
commitd39eedfc6d05b42a9998e46504634cba0639b460 (patch)
treebada236adb8d5517a47a56c87fa48e8cb3b01055
parentfeaccc063f3cb4a8a4eedf6d775c3e2da06e968f (diff)
Release version 7.67.0+8v7.67.0+8
Make libcurl test more robust and verbose
-rw-r--r--curl/manifest2
-rw-r--r--libcurl/manifest2
-rw-r--r--libcurl/tests/basic/driver.c67
-rw-r--r--libcurl/tests/basic/testscript2
4 files changed, 66 insertions, 7 deletions
diff --git a/curl/manifest b/curl/manifest
index 4a1c446..e12ccaa 100644
--- a/curl/manifest
+++ b/curl/manifest
@@ -1,6 +1,6 @@
: 1
name: curl
-version: 7.67.0+7
+version: 7.67.0+8
summary: Command line tool for transferring data with URLs
license: cURL ; MIT/X derivate license.
topics: HTTP, FTP, URL, data transfer
diff --git a/libcurl/manifest b/libcurl/manifest
index ba939cf..83cb99f 100644
--- a/libcurl/manifest
+++ b/libcurl/manifest
@@ -1,6 +1,6 @@
: 1
name: libcurl
-version: 7.67.0+7
+version: 7.67.0+8
project: curl
summary: C library for transferring data with URLs
license: cURL ; MIT/X derivate license.
diff --git a/libcurl/tests/basic/driver.c b/libcurl/tests/basic/driver.c
index f784a88..13b731c 100644
--- a/libcurl/tests/basic/driver.c
+++ b/libcurl/tests/basic/driver.c
@@ -3,42 +3,92 @@
*/
#include <stdio.h>
#include <assert.h>
+#include <string.h> /* strcmp() */
#include <curl/curl.h>
/* Usage: argv[0] <URL>
*
- * Request the specified URL and print the response to stdout.
+ * Request the specified URL following location for 3xx responses and print
+ * the 200 response body to stdout.
+ *
+ * --verbose
+ * Print additional information (API calls, HTTP headers, etc) to stderr.
*/
int
main (int argc, char* argv[])
{
- assert (argc == 2);
+ int v = 0;
- const char* url = argv[1];
+ int i = 1;
+ for (; i < argc; ++i)
+ {
+ const char* o = argv[i];
- curl_global_init (CURL_GLOBAL_DEFAULT);
+ if (strcmp (o, "--verbose") == 0)
+ v = 1;
+ else
+ break;
+ }
+
+ assert (i + 1 == argc);
+
+ const char* url = argv[i];
int r = 1;
+ if (v != 0)
+ fprintf (stderr, "calling curl_global_init()\n");
+
+ curl_global_init (CURL_GLOBAL_DEFAULT);
+
+ if (v != 0)
+ fprintf (stderr, "calling curl_easy_init()\n");
+
CURL* curl = curl_easy_init ();
if (curl != NULL)
{
+ if (v != 0)
+ fprintf (stderr, "calling curl_easy_setopt()\n");
+
curl_easy_setopt (curl, CURLOPT_URL, url);
+ curl_easy_setopt (curl, CURLOPT_TIMEOUT, 600L); // 10 mins.
curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
+ char agent[] = "libcurl-test/" LIBCURL_VERSION;
+ curl_easy_setopt (curl, CURLOPT_USERAGENT, agent);
+
+ if (v != 0)
+ curl_easy_setopt (curl, CURLOPT_VERBOSE, 1L);
+
+ if (v != 0)
+ fprintf (stderr, "calling curl_easy_perform()\n");
+
CURLcode cr = curl_easy_perform (curl);
if (cr == CURLE_OK)
{
+ if (v != 0)
+ fprintf (stderr, "calling curl_easy_getinfo()\n");
+
long status;
cr = curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &status);
if (cr == CURLE_OK)
{
if (status == 200)
+ {
+ if (v != 0)
+ fprintf (stderr, "calling fflush()\n");
+
+ /* Flush the response body.
+ */
+ if (fflush (stdout) != 0)
+ fprintf (stderr, "failed to flush stdout\n");
+
r = 0;
+ }
else
fprintf (stderr, "HTTP error: status code %ld\n", status);
}
@@ -58,6 +108,15 @@ main (int argc, char* argv[])
else
fprintf (stderr, "curl_easy_init() failed\n");
+ if (v != 0)
+ fprintf (stderr, "calling curl_global_cleanup()\n");
+
curl_global_cleanup ();
+
+ /* Make sure the verbose output and diagnostics is printed properly.
+ */
+ if (fflush (stderr) != 0)
+ r = 1;
+
return r;
}
diff --git a/libcurl/tests/basic/testscript b/libcurl/tests/basic/testscript
index 054eead..2294ba0 100644
--- a/libcurl/tests/basic/testscript
+++ b/libcurl/tests/basic/testscript
@@ -3,7 +3,7 @@
: http
:
-$* 'http://www.example.com' >>~%EOO%
+$* --verbose 'http://www.example.com' >>~%EOO% 2>!
%.+
EOO