From 2d0e9b40d3237b1450cbbfbcb996da244d964898 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 3 May 2019 13:18:12 +0200 Subject: urlapi: add CURLUPART_ZONEID to set and get The zoneid can be used with IPv6 numerical addresses. Updated test 1560 to verify. Closes #3834 --- tests/libtest/lib1560.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/libtest') 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; -- cgit v1.2.3