mirror of
https://github.com/curl/curl.git
synced 2026-08-24 23:43:40 +03:00
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
This commit is contained in:
parent
0c6112a139
commit
0b85969226
5 changed files with 130 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
66
tests/libtest/lib3010.c
Normal file
66
tests/libtest/lib3010.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue