I expect this block to save the altsvc cache to "altsvc.txt" but it does not.
When the curl_easy_reset line (noted with a comment) is removed, "altsvc.txt" is saved as expected.
/********* Sample code generated by the curl command line tool **********
* All curl_easy_setopt() options are documented at:
* https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
************************************************************************/
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
curl_easy_setopt(hnd, CURLOPT_URL, "https://integralblue.com");
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.68.0");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS);
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(hnd, CURLOPT_ALTSVC, "altsvc.txt");
/* Here is a list of options the curl code used that cannot get generated
as source easily. You may select to either not use them or implement
them yourself.
CURLOPT_WRITEDATA set to a objectpointer
CURLOPT_INTERLEAVEDATA set to a objectpointer
CURLOPT_WRITEFUNCTION set to a functionpointer
CURLOPT_READDATA set to a objectpointer
CURLOPT_READFUNCTION set to a functionpointer
CURLOPT_SEEKDATA set to a objectpointer
CURLOPT_SEEKFUNCTION set to a functionpointer
CURLOPT_ERRORBUFFER set to a objectpointer
CURLOPT_STDERR set to a objectpointer
CURLOPT_HEADERFUNCTION set to a functionpointer
CURLOPT_HEADERDATA set to a objectpointer
*/
ret = curl_easy_perform(hnd);
curl_easy_reset(hnd); // line added
curl_easy_cleanup(hnd);
hnd = NULL;
return (int)ret;
}
/**** End of sample code ****/
I don't think it should save the file in the reset call, but the reset should not impact the alt-svc cache so it should then be saved correctly by curl_easy_cleanup(). I take it you're saying that's not what's happening?
The alt-svc cache survives a call to curl_easy_reset fine, but the file
name to use for saving the cache was cleared. Now the alt-svc cache has
a copy of the file name to survive handle resets.
Added test 1908 to verify.
Reported-by: Craig Andrews
Fixes#4898
I did this
I expect this block to save the altsvc cache to "altsvc.txt" but it does not.
When the
curl_easy_reset
line (noted with a comment) is removed, "altsvc.txt" is saved as expected.Currently, the alt svc cache is only saved in
curl_close
which is called bycurl_easy_cleanup
:https://github.com/curl/curl/blob/curl-7_68_0/lib/url.c#L383
https://github.com/curl/curl/blob/curl-7_68_0/lib/easy.c#L738
It should also be saved when
curl_easy_reset
is called.I believe that adding
at https://github.com/curl/curl/blob/curl-7_68_0/lib/easy.c#L941 would address this issue.
I expected the following
curl_easy_reset
should save the altsvc cache file.curl/libcurl version
operating system
The text was updated successfully, but these errors were encountered: