Test 1589 verifies.
Closes #21485
#endif /* !USE_SSL */
}
+#ifndef CURL_DISABLE_PROXY
+static void changeproxy(struct Curl_easy *data)
+{
+ Curl_auth_digest_cleanup(&data->state.proxydigest);
+ memset(&data->state.authproxy, 0, sizeof(data->state.authproxy));
+}
+
static CURLcode setopt_long_proxy(struct Curl_easy *data, CURLoption option,
long arg)
{
-#ifndef CURL_DISABLE_PROXY
struct UserDefined *s = &data->set;
switch(option) {
case CURLOPT_PROXYPORT:
if((arg < 0) || (arg > UINT16_MAX))
return CURLE_BAD_FUNCTION_ARGUMENT;
+ if(arg != s->proxyport)
+ changeproxy(data);
s->proxyport = (uint16_t)arg;
break;
case CURLOPT_PROXYAUTH:
return CURLE_UNKNOWN_OPTION;
}
return CURLE_OK;
+}
#else
+static CURLcode setopt_long_proxy(struct Curl_easy *data, CURLoption option,
+ long arg)
+{
(void)data;
(void)option;
(void)arg;
return CURLE_UNKNOWN_OPTION;
-#endif
}
+#endif
static CURLcode setopt_long_http(struct Curl_easy *data, CURLoption option,
long arg)
!strcmp(data->set.str[STRING_PROXY], proxy))
return CURLE_OK; /* same one as before */
- Curl_auth_digest_cleanup(&data->state.proxydigest);
- memset(&data->state.authproxy, 0, sizeof(data->state.authproxy));
+ changeproxy(data);
return Curl_setstropt(&data->set.str[STRING_PROXY], proxy);
}
test1564 test1565 test1566 test1567 test1568 test1569 test1570 test1571 \
test1572 test1573 test1574 test1575 test1576 test1577 test1578 test1579 \
test1580 test1581 test1582 test1583 test1584 test1585 test1586 test1587 \
-test1588 \
-\
-test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
-test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
-test1606 test1607 test1608 test1609 test1610 test1611 test1612 test1613 \
-test1614 test1615 test1616 test1617 test1618 test1619 test1620 test1621 \
-test1622 test1623 test1624 test1625 test1626 test1627 \
+test1588 test1589 test1590 test1591 test1592 test1593 test1594 test1595 \
+test1596 test1597 test1598 test1599 test1600 test1601 test1602 test1603 \
+test1604 test1605 test1606 test1607 test1608 test1609 test1610 test1611 \
+test1612 test1613 test1614 test1615 test1616 test1617 test1618 test1619 \
+test1620 test1621 test1622 test1623 test1624 test1625 test1626 test1627 \
\
test1630 test1631 test1632 test1633 test1634 test1635 test1636 test1637 \
test1638 test1639 test1640 test1641 test1642 test1643 test1644 \
--- /dev/null
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP proxy
+HTTP proxy Digest auth
+</keywords>
+</info>
+
+# Server-side
+<reply>
+
+# this is returned first since we get no proxy-auth
+<data crlf="headers">
+HTTP/1.1 407 Authorization Required to proxy me my dear
+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
+Content-Length: 33
+
+And you should ignore this data.
+</data>
+
+# then this is returned when we get proxy-auth
+<data1000 crlf="headers">
+HTTP/1.1 200 OK
+Content-Length: 21
+Server: no
+
+Nice proxy auth sir!
+</data1000>
+
+<datacheck crlf="headers">
+HTTP/1.1 407 Authorization Required to proxy me my dear
+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
+Content-Length: 33
+
+HTTP/1.1 200 OK
+Content-Length: 21
+Server: no
+
+Nice proxy auth sir!
+HTTP/1.1 407 Authorization Required to proxy me my dear
+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
+Content-Length: 33
+
+HTTP/1.1 200 OK
+Content-Length: 21
+Server: no
+
+Nice proxy auth sir!
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+http-proxy
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib%TESTNUMBER
+</tool>
+<features>
+!SSPI
+crypto
+proxy
+digest
+</features>
+<name>
+HTTP proxy auth Digest, then change proxy port and do it again
+</name>
+<command>
+http://test.remote.example.com/path/%TESTNUMBER %HOSTIP %HTTPPORT %PROXYPORT silly:person
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="headers">
+GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
+Host: test.remote.example.com
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
+Host: test.remote.example.com
+Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="/path/%TESTNUMBER", response="9a547f8fa81cff330c68095603f3819e"
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+</protocol>
+<proxy crlf="headers">
+GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
+Host: test.remote.example.com
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
+Host: test.remote.example.com
+Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="/path/%TESTNUMBER", response="9a547f8fa81cff330c68095603f3819e"
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+</proxy>
+
+</verify>
+</testcase>
lib1552.c lib1553.c lib1554.c lib1555.c lib1556.c lib1557.c lib1558.c \
lib1559.c lib1560.c lib1564.c lib1565.c \
lib1567.c lib1568.c lib1569.c lib1571.c \
- lib1576.c lib1582.c lib1587.c lib1588.c \
+ lib1576.c lib1582.c lib1587.c lib1588.c lib1589.c \
lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
lib1598.c lib1599.c \
lib1662.c \
const char *libtest_arg2 = NULL;
const char *libtest_arg3 = NULL;
const char *libtest_arg4 = NULL;
+const char *libtest_arg5 = NULL;
int test_argc;
const char **test_argv;
int testnum;
if(argc > 5)
libtest_arg4 = argv[5];
+ if(argc > 6)
+ libtest_arg5 = argv[6];
+
testnum = 0;
env = getenv("CURL_TESTNUM");
if(env) {
extern const char *libtest_arg2; /* set by first.c to the argv[2] or NULL */
extern const char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
extern const char *libtest_arg4; /* set by first.c to the argv[4] or NULL */
+extern const char *libtest_arg5; /* set by first.c to the argv[5] or NULL */
/* argc and argv as passed in to the main() function */
extern int test_argc;
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+/*
+ * argv1 = URL
+ * argv2 = proxy host
+ * argv3 = proxy1 port
+ * argv4 = proxy2 port
+ * argv5 = proxyuser:password
+ */
+
+#include "first.h"
+
+static CURLcode init1589(CURL *curl, const char *url,
+ const char *userpwd, const char *proxy,
+ int port)
+{
+ CURLcode result = CURLE_OK;
+
+ res_easy_setopt(curl, CURLOPT_URL, url);
+ if(result)
+ goto init_failed;
+
+ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
+ if(result)
+ goto init_failed;
+
+ res_easy_setopt(curl, CURLOPT_PROXYPORT, (long)port);
+ if(result)
+ goto init_failed;
+
+ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
+ if(result)
+ goto init_failed;
+
+ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
+ if(result)
+ goto init_failed;
+
+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ if(result)
+ goto init_failed;
+#if 0
+ res_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
+ if(result)
+ goto init_failed;
+#endif
+
+ res_easy_setopt(curl, CURLOPT_HEADER, 1L);
+ if(result)
+ goto init_failed;
+
+ return CURLE_OK; /* success */
+
+init_failed:
+ return result; /* failure */
+}
+
+static CURLcode run1589(CURL *curl, const char *url, const char *userpwd,
+ const char *proxy, int port)
+{
+ CURLcode result = CURLE_OK;
+
+ result = init1589(curl, url, userpwd, proxy, port);
+ if(result)
+ return result;
+
+ return curl_easy_perform(curl);
+}
+
+static CURLcode test_lib1589(const char *URL)
+{
+ CURLcode result = CURLE_OK;
+ CURL *curl = NULL;
+ const char *proxy = libtest_arg2;
+ /* !checksrc! disable BANNEDFUNC 2 */
+ int port1 = atoi(libtest_arg3);
+ int port2 = atoi(libtest_arg4);
+ const char *proxyuserpwd = libtest_arg5;
+
+ if(test_argc < 5)
+ return TEST_ERR_MAJOR_BAD;
+
+ res_global_init(CURL_GLOBAL_ALL);
+ if(result)
+ return result;
+
+ curl = curl_easy_init();
+ if(!curl) {
+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ start_test_timing();
+
+ result = run1589(curl, URL, proxyuserpwd, proxy, port1);
+ if(result)
+ goto test_cleanup;
+
+ curl_mfprintf(stderr, "lib1589: now we do the request again\n");
+
+ result = run1589(curl, URL, proxyuserpwd, proxy, port2);
+
+test_cleanup:
+
+ /* proper cleanup sequence - type PB */
+
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return result;
+}