diff options
author | Daniel Stenberg <daniel@haxx.se> | 2019-05-03 13:18:12 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-05-05 15:52:46 +0200 |
commit | 2d0e9b40d3237b1450cbbfbcb996da244d964898 (patch) | |
tree | 79f952f5ede7ce5af423fbd480c8ea3c7df3de6f /tests | |
parent | 0eec832603d3a4ba9ae69a16351cf29c37f7fb7c (diff) | |
download | curl-2d0e9b40d3237b1450cbbfbcb996da244d964898.tar.gz |
urlapi: add CURLUPART_ZONEID to set and get
The zoneid can be used with IPv6 numerical addresses.
Updated test 1560 to verify.
Closes #3834
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/test1560 | 2 | ||||
-rw-r--r-- | tests/libtest/lib1560.c | 38 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/data/test1560 b/tests/data/test1560 index 9f6a122a0..a0e603bfc 100644 --- a/tests/data/test1560 +++ b/tests/data/test1560 @@ -38,6 +38,8 @@ we got https://[::1]/hello.html we got https://example.com/hello.html we got https://[fe80::20c:29ff:fe9c:409b%25eth0]/hello.html we got [fe80::20c:29ff:fe9c:409b] +we got eth0 +we got https://[fe80::20c:29ff:fe9c:409b%25clown]/hello.html success </stdout> </verify> diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index 0b9495767..5ad7134d0 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -414,6 +414,10 @@ static int checkurl(const char *url, const char *out) /* !checksrc! disable SPACEBEFORECOMMA 1 */ static struct setcase set_parts_list[] = { + {"https://[::1%25fake]:1234/", + "zoneid=NULL,", + "https://[::1]:1234/", + 0, 0, CURLUE_OK, CURLUE_OK}, {"https://host:1234/", "port=NULL,", "https://host/", @@ -547,6 +551,8 @@ static CURLUPart part2id(char *part) return CURLUPART_QUERY; if(!strcmp("fragment", part)) return CURLUPART_FRAGMENT; + if(!strcmp("zoneid", part)) + return CURLUPART_ZONEID; return 9999; /* bad input => bad output */ } @@ -571,6 +577,9 @@ static CURLUcode updateurl(CURLU *u, const char *cmd, unsigned int setflags) /* for debugging this */ fprintf(stderr, "%s = %s [%d]\n", part, value, (int)what); #endif + if(what > CURLUPART_ZONEID) + fprintf(stderr, "UNKNOWN part '%s'\n", part); + if(!strcmp("NULL", value)) uc = curl_url_set(u, what, NULL, setflags); else if(!strcmp("\"\"", value)) @@ -942,6 +951,35 @@ static int scopeid(void) curl_free(url); } + rc = curl_url_get(u, CURLUPART_ZONEID, &url, 0); + if(rc != CURLUE_OK) { + fprintf(stderr, "%s:%d curl_url_get CURLUPART_ZONEID returned %d\n", + __FILE__, __LINE__, (int)rc); + error++; + } + else { + printf("we got %s\n", url); + curl_free(url); + } + + rc = curl_url_set(u, CURLUPART_ZONEID, "clown", 0); + if(rc != CURLUE_OK) { + fprintf(stderr, "%s:%d curl_url_set CURLUPART_ZONEID returned %d\n", + __FILE__, __LINE__, (int)rc); + error++; + } + + rc = curl_url_get(u, CURLUPART_URL, &url, 0); + if(rc != CURLUE_OK) { + fprintf(stderr, "%s:%d curl_url_get CURLUPART_URL returned %d\n", + __FILE__, __LINE__, (int)rc); + error++; + } + else { + printf("we got %s\n", url); + curl_free(url); + } + curl_url_cleanup(u); return error; |