summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-09-05 21:21:26 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-09-06 09:54:54 +0200
commitf93455eb04b57b2d002244bed1f0b59b94c2f0c7 (patch)
treea403a1dffdc45c2b37fa33a69f1aa0af3b1bb52c /tests
parent8ca54a03ea08a7b0cf0a402018f329bd93124216 (diff)
downloadcurl-f93455eb04b57b2d002244bed1f0b59b94c2f0c7.tar.gz
altsvc: clone setting in curl_easy_duphandlebagder/altsvc-duphandle
The cache content is not duplicated, like other caches, but the setting and specified file name are. Test 1908 is extended to verify this somewhat. Since the duplicated handle gets the same file name, the test unfortunately overwrites the same file twice (with different contents) which makes it hard to check automatically. Closes #5923
Diffstat (limited to 'tests')
-rw-r--r--tests/data/test190815
-rw-r--r--tests/libtest/lib1908.c15
-rw-r--r--tests/unit/unit1654.c4
3 files changed, 31 insertions, 3 deletions
diff --git a/tests/data/test1908 b/tests/data/test1908
index bf23ef9fc..00ce98a6a 100644
--- a/tests/data/test1908
+++ b/tests/data/test1908
@@ -8,7 +8,7 @@ CURLINFO_EFFECTIVE_URL
# Server-side
<reply>
<data nocheck="yes">
-HTTP/1.1 200 OK
+HTTP/1.1 200 OK swsbounce
Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Content-Type: text/html
@@ -17,6 +17,15 @@ Content-Length: 0
alt-svc: h2="3dbbdetxoyw4nsp6c3cc456oj2ays6s43ezxzsfxxri3h5xqd.example:443"; ma=315360000; persist=1
</data>
+
+# This is the second response
+<data1 nocheck="yes">
+HTTP/1.1 200 OK
+Connection: close
+Content-Length: 0
+alt-svc: h2="second.example:443"; ma=315360000;
+
+</data1>
</reply>
# Client-side
@@ -56,6 +65,10 @@ GET /1908 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
+GET /1908 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
</protocol>
<stripfile>
# strip out the (dynamic) expire date from the file so that the rest
diff --git a/tests/libtest/lib1908.c b/tests/libtest/lib1908.c
index bacbc9710..30e7d8019 100644
--- a/tests/libtest/lib1908.c
+++ b/tests/libtest/lib1908.c
@@ -39,7 +39,22 @@ int test(char *URL)
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_ALTSVC, "log/altsvc-1908");
ret = curl_easy_perform(hnd);
+
+ if(!ret) {
+ /* make a copy and check that this also has alt-svc activated */
+ CURL *also = curl_easy_duphandle(hnd);
+ if(also) {
+ ret = curl_easy_perform(also);
+ /* we close the second handle first, which makes it store the alt-svc
+ file only to get overwritten when the next handle is closed! */
+ curl_easy_cleanup(also);
+ }
+ }
+
curl_easy_reset(hnd);
+
+ /* using the same file name for the alt-svc cache, this clobbers the
+ content just written from the 'also' handle */
curl_easy_cleanup(hnd);
}
curl_global_cleanup();
diff --git a/tests/unit/unit1654.c b/tests/unit/unit1654.c
index 79e97631c..6274d0af8 100644
--- a/tests/unit/unit1654.c
+++ b/tests/unit/unit1654.c
@@ -54,7 +54,7 @@ UNITTEST_START
return 1;
result = Curl_altsvc_load(asi, arg);
if(result) {
- Curl_altsvc_cleanup(asi);
+ Curl_altsvc_cleanup(&asi);
return result;
}
curl = curl_easy_init();
@@ -131,7 +131,7 @@ UNITTEST_START
curl_easy_cleanup(curl);
fail:
- Curl_altsvc_cleanup(asi);
+ Curl_altsvc_cleanup(&asi);
return unitfail;
}
UNITTEST_STOP