dav/webdav.c

changeset 21
78935b45e2ce
parent 19
18efd2c2973d
child 22
e593f7e41be0
--- a/dav/webdav.c	Sat Aug 17 14:57:17 2013 +0200
+++ b/dav/webdav.c	Mon Aug 19 12:50:42 2013 +0200
@@ -47,6 +47,9 @@
     }
     context->sessions = NULL;
     context->namespaces = ucx_map_new(16);
+    context->http_proxy = NULL;
+    context->https_proxy = NULL;
+    context->no_proxy = NULL;
     if(!context->namespaces) {
         free(context);
         return NULL;
@@ -121,6 +124,24 @@
     }
     sn->context = context;
     sn->handle = curl_easy_init();
+    
+    // set proxy
+    if(sstrprefix(url, S("https"))) {
+        if(context->https_proxy) {
+            //printf("use https_proxy: %s\n", context->https_proxy);
+            curl_easy_setopt(sn->handle, CURLOPT_PROXY, context->https_proxy);
+        }
+    } else {
+        if(context->http_proxy) {
+            //printf("use http_proxy: %s\n", context->http_proxy);
+            curl_easy_setopt(sn->handle, CURLOPT_PROXY, context->http_proxy);
+        }
+    }
+    if(context->no_proxy) {
+        //printf("use no_proxy: %s\n", context->no_proxy);
+        curl_easy_setopt(sn->handle, CURLOPT_NOPROXY, context->no_proxy);
+    }
+    // set url
     curl_easy_setopt(sn->handle, CURLOPT_URL, base_url);
     
     sn->mp = ucx_mempool_new(1024);

mercurial