--- /dev/null
+<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\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+GET /%20/with/%20space/%TESTNUMBER0002 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+</protocol>
+<stdout>
+res 0
+status 200
+redirects 1
+effectiveurl http://%HOSTIP:%HTTPPORT/%20/with/%20space/%TESTNUMBER0002
+redirecturl blank
+</stdout>
+<errorcode>
+0
+</errorcode>
+</verify>
+</testcase>
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 \
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
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * 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
/* 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;
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);
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"
(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;
}