test1543: verify CURLINFO_EFFECTIVE_URL with CURLOPT_CURLU set
Triggered by a bug report from Adam Light: https://curl.se/mail/lib-2022-06/0013.html - which ended up being mostly a misunderstanding of how CURLINFO_EFFECTIVE_URL works. Closes #8971
This commit is contained in:
parent
90a7017acb
commit
5121d98c22
@ -193,7 +193,7 @@ test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \
|
||||
test1516 test1517 test1518 test1519 test1520 test1521 test1522 test1523 \
|
||||
test1524 test1525 test1526 test1527 test1528 test1529 test1530 test1531 \
|
||||
test1532 test1533 test1534 test1535 test1536 test1537 test1538 test1539 \
|
||||
test1540 test1542 \
|
||||
test1540 test1542 test1543 \
|
||||
\
|
||||
test1550 test1551 test1552 test1553 test1554 test1555 test1556 test1557 \
|
||||
test1558 test1559 test1560 test1561 test1562 test1563 test1564 test1565 \
|
||||
|
||||
76
tests/data/test1543
Normal file
76
tests/data/test1543
Normal file
@ -0,0 +1,76 @@
|
||||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_CURLU
|
||||
</keywords>
|
||||
</info>
|
||||
#
|
||||
# Similar to 1518 but using CURLOPT_CURLU
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data2 nocheck="yes">
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 17 Mar 2016 14:41:00 GMT
|
||||
Server: test-server/fake
|
||||
X-Special: swsclose
|
||||
Content-Length: 0
|
||||
Connection: close
|
||||
|
||||
</data2>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 redirect
|
||||
Date: Thu, 17 Mar 2016 14:41:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/plain; charset=US-ASCII
|
||||
Location: ../%TESTNUMBER0002
|
||||
Content-Length: 0
|
||||
Connection: close
|
||||
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# tool is what to use instead of 'curl'
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<name>
|
||||
CURLOPT_CURLU, URL with space and CURLINFO_EFFECTIVE_URL
|
||||
</name>
|
||||
<command>
|
||||
"http://%HOSTIP:%HTTPPORT/ /with/ space/ /file"
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
GET /%20/with/%20space/%20/file HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Accept: */*
|
||||
|
||||
GET /%20/with/%20space/%TESTNUMBER0002 HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Accept: */*
|
||||
|
||||
</protocol>
|
||||
<stdout>
|
||||
res 0
|
||||
status 200
|
||||
redirects 1
|
||||
effectiveurl http://%HOSTIP:%HTTPPORT/%20/with/%20space/%TESTNUMBER0002
|
||||
redirecturl blank
|
||||
</stdout>
|
||||
<errorcode>
|
||||
0
|
||||
</errorcode>
|
||||
</verify>
|
||||
</testcase>
|
||||
@ -55,7 +55,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
|
||||
lib1518 lib1520 lib1521 lib1522 lib1523 \
|
||||
lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \
|
||||
lib1534 lib1535 lib1536 lib1537 lib1538 lib1539 \
|
||||
lib1540 lib1542 \
|
||||
lib1540 lib1542 lib1543 \
|
||||
lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \
|
||||
lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 lib1568 lib1569 \
|
||||
lib1591 lib1592 lib1593 lib1594 lib1596 \
|
||||
@ -579,6 +579,9 @@ lib1542_SOURCES = lib1542.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) $(WARNLESS)
|
||||
lib1542_LDADD = $(TESTUTIL_LIBS)
|
||||
lib1542_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
lib1543_SOURCES = lib1518.c $(SUPPORTFILES)
|
||||
lib1543_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1543
|
||||
|
||||
lib1550_SOURCES = lib1550.c $(SUPPORTFILES)
|
||||
lib1550_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1517
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -25,6 +25,16 @@
|
||||
|
||||
/* Test inspired by github issue 3340 */
|
||||
|
||||
static size_t writecb(char *buffer, size_t size, size_t nitems,
|
||||
void *outstream)
|
||||
{
|
||||
(void)buffer;
|
||||
(void)size;
|
||||
(void)nitems;
|
||||
(void)outstream;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
@ -33,17 +43,34 @@ int test(char *URL)
|
||||
long curlRedirectCount;
|
||||
char *effectiveUrl = NULL;
|
||||
char *redirectUrl = NULL;
|
||||
|
||||
#ifdef LIB1543
|
||||
CURLU *urlu = NULL;
|
||||
#endif
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
#ifdef LIB1543
|
||||
/* set CURLOPT_URLU */
|
||||
{
|
||||
CURLUcode rc = CURLUE_OK;
|
||||
urlu = curl_url();
|
||||
if(urlu)
|
||||
rc = curl_url_set(urlu, CURLUPART_URL, URL, CURLU_ALLOW_SPACE);
|
||||
if(!urlu || rc) {
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_CURLU, urlu);
|
||||
}
|
||||
test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
#else
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
/* just to make it explicit and visible in this test: */
|
||||
test_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
|
||||
#endif
|
||||
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
@ -52,6 +79,7 @@ int test(char *URL)
|
||||
curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &curlRedirectCount);
|
||||
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effectiveUrl);
|
||||
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirectUrl);
|
||||
res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
|
||||
|
||||
printf("res %d\n"
|
||||
"status %d\n"
|
||||
@ -62,13 +90,15 @@ int test(char *URL)
|
||||
(int)curlResponseCode,
|
||||
(int)curlRedirectCount,
|
||||
effectiveUrl,
|
||||
redirectUrl);
|
||||
redirectUrl ? redirectUrl : "blank");
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
#ifdef LIB1543
|
||||
curl_url_cleanup(urlu);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user