summaryrefslogtreecommitdiff
path: root/tests/libtest
diff options
context:
space:
mode:
authorNicolas Sterchele <sterchelen@gmail.com>2020-07-10 20:05:21 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-07-27 12:15:44 +0200
commit0b859692265bccd5ffdc1be27e7307b2d2fa7c1a (patch)
tree6baa603c8ace956328d218a9b8d9ab1ea3cd38a0 /tests/libtest
parent0c6112a139c1133f7bdfc440903c0e5602c84d90 (diff)
downloadcurl-0b859692265bccd5ffdc1be27e7307b2d2fa7c1a.tar.gz
getinfo: reset retry-after value in initinfo
- Avoid re-using retry_after value from preceding request - Add libtest 3010 to verify Reported-by: joey-l-us on github Fixes #5661 Closes #5672
Diffstat (limited to 'tests/libtest')
-rw-r--r--tests/libtest/Makefile.inc6
-rw-r--r--tests/libtest/lib3010.c66
2 files changed, 71 insertions, 1 deletions
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index bc193bd9d..8ad7dc4e6 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -59,7 +59,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
lib1558 lib1559 lib1560 lib1564 lib1565 \
lib1591 lib1592 lib1593 lib1594 lib1596 \
lib1900 lib1905 lib1906 lib1907 lib1908 lib1910 \
- lib2033
+ lib2033 lib3010
chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \
../../lib/curl_ctype.c ../../lib/dynbuf.c ../../lib/strdup.c
@@ -649,3 +649,7 @@ lib1910_CPPFLAGS = $(AM_CPPFLAGS)
lib2033_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib2033_LDADD = $(TESTUTIL_LIBS)
lib2033_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PIPELINING
+
+lib3010_SOURCES = lib3010.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
+lib3010_LDADD = $(TESTUTIL_LIBS)
+lib3010_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/tests/libtest/lib3010.c b/tests/libtest/lib3010.c
new file mode 100644
index 000000000..9c24b2f52
--- /dev/null
+++ b/tests/libtest/lib3010.c
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020 - 2020, Nicolas Sterchele, <nicolas@sterchelen.net>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "memdebug.h"
+
+int test(char *URL)
+{
+ CURLcode ret = CURLE_OK;
+ CURL *curl = NULL;
+ curl_off_t retry_after;
+ char *follow_url = NULL;
+
+ curl_global_init(CURL_GLOBAL_ALL);
+ curl = curl_easy_init();
+
+ if(curl) {
+ curl_easy_setopt(curl, CURLOPT_URL, URL);
+ ret = curl_easy_perform(curl);
+ if(ret) {
+ fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
+ __FILE__, __LINE__, ret, curl_easy_strerror(ret));
+ goto test_cleanup;
+ }
+ curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &follow_url);
+ curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry_after);
+ printf("Retry-After: %" CURL_FORMAT_CURL_OFF_T "\n", retry_after);
+ curl_easy_setopt(curl, CURLOPT_URL, follow_url);
+ ret = curl_easy_perform(curl);
+ if(ret) {
+ fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
+ __FILE__, __LINE__, ret, curl_easy_strerror(ret));
+ goto test_cleanup;
+ }
+
+ curl_easy_reset(curl);
+ curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry_after);
+ printf("Retry-After: %" CURL_FORMAT_CURL_OFF_T "\n", retry_after);
+ }
+
+test_cleanup:
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+
+ return ret;
+}
+