summaryrefslogtreecommitdiff
path: root/Utilities
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-03-02 17:19:23 -0500
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-03-02 17:19:23 -0500
commit725645baaa6463c870cd203ca91be2b4b958c568 (patch)
treea15298d0ed58d9c10706a282c76b2da07676f5e0 /Utilities
parent1b68c76b1978b8edd4703d31b8c2befc65b60a0f (diff)
downloadcmake-725645baaa6463c870cd203ca91be2b4b958c568.tar.gz
ENH: Temporary proxy support
Diffstat (limited to 'Utilities')
-rw-r--r--Utilities/cmxmlrpc/xmlrpc_curl_transport.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/Utilities/cmxmlrpc/xmlrpc_curl_transport.c b/Utilities/cmxmlrpc/xmlrpc_curl_transport.c
index 14399db900..7ad97f7530 100644
--- a/Utilities/cmxmlrpc/xmlrpc_curl_transport.c
+++ b/Utilities/cmxmlrpc/xmlrpc_curl_transport.c
@@ -281,6 +281,68 @@ setupCurlSession(xmlrpc_env * const envP,
xmlrpc_mem_block * const callXmlP,
xmlrpc_mem_block * const responseXmlP) {
+ char proxy[1024];
+ char proxyUser[1024];
+ int proxy_type = 0;
+
+ if ( getenv("HTTP_PROXY") )
+ {
+ proxy_type = 1;
+ if (getenv("HTTP_PROXY_PORT") )
+ {
+ sprintf(proxy, "%s:%s", getenv("HTTP_PROXY"), getenv("HTTP_PROXY_PORT"));
+ }
+ else
+ {
+ sprintf(proxy, "%s", getenv("HTTP_PROXY"));
+ }
+ if ( getenv("HTTP_PROXY_TYPE") )
+ {
+ /* HTTP/SOCKS4/SOCKS5 */
+ if ( strcmp(getenv("HTTP_PROXY_TYPE"), "HTTP") == 0 )
+ {
+ proxy_type = 1;
+ }
+ else if ( strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS4") == 0 )
+ {
+ proxy_type = 2;
+ }
+ else if ( strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS5") == 0 )
+ {
+ proxy_type = 3;
+ }
+ }
+ if ( getenv("HTTP_PROXY_USER") )
+ {
+ strcpy(proxyUser, getenv("HTTP_PROXY_USER"));
+ }
+ if ( getenv("HTTP_PROXY_PASSWD") )
+ {
+ strcat(proxyUser, ":");
+ strcat(proxyUser, getenv("HTTP_PROXY_PASSWD"));
+ }
+ }
+ /* Using proxy */
+ if ( proxy_type > 0 )
+ {
+ curl_easy_setopt(curlSessionP, CURLOPT_PROXY, proxy);
+ switch (proxy_type)
+ {
+ case 2:
+ curl_easy_setopt(curlSessionP, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ break;
+ case 3:
+ curl_easy_setopt(curlSessionP, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ break;
+ default:
+ curl_easy_setopt(curlSessionP, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ if (*proxyUser)
+ {
+ curl_easy_setopt(curlSessionP, CURLOPT_PROXYUSERPWD, proxyUser);
+ }
+ }
+ }
+
curl_easy_setopt(curlSessionP, CURLOPT_POST, 1 );
curl_easy_setopt(curlSessionP, CURLOPT_URL, curlTransactionP->serverUrl);
XMLRPC_MEMBLOCK_APPEND(char, envP, callXmlP, "\0", 1);