summaryrefslogtreecommitdiff
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
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
-rw-r--r--lib/getinfo.c1
-rw-r--r--tests/data/Makefile.inc2
-rw-r--r--tests/data/test301057
-rw-r--r--tests/libtest/Makefile.inc6
-rw-r--r--tests/libtest/lib3010.c66
5 files changed, 130 insertions, 2 deletions
diff --git a/lib/getinfo.c b/lib/getinfo.c
index 675a616f0..82691dcc7 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -78,6 +78,7 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
info->conn_local_ip[0] = '\0';
info->conn_primary_port = 0;
info->conn_local_port = 0;
+ info->retry_after = 0;
info->conn_scheme = 0;
info->conn_protocol = 0;
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index 667d7951a..e5dfbfde4 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -225,4 +225,4 @@ test2080 \
test2100 \
\
test3000 test3001 \
-test3002 test3003 test3004 test3005 test3006 test3007
+test3002 test3003 test3004 test3005 test3006 test3007 test3010
diff --git a/tests/data/test3010 b/tests/data/test3010
new file mode 100644
index 000000000..1372a79d2
--- /dev/null
+++ b/tests/data/test3010
@@ -0,0 +1,57 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP Basic
+RETRY-AFTER
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 301 Moved Permanently
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Type: text/html
+Content-Length: 0
+Retry-After: 2
+Location: /30100002
+
+</data>
+<data2>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Type: text/html
+Content-Length: 0
+
+</data2>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+
+<name>
+HTTP retry-after reset
+</name>
+<tool>
+lib3010
+</tool>
+
+<command>
+%HOSTIP:%HTTPPORT/3010
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<stdout>
+Retry-After: 2
+Retry-After: 0
+</stdout>
+</verify>
+</testcase>
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;
+}
+