Wed, 14 Oct 2015 11:49:39 +0200
using Depth: 0 for non collection resources
libidav/methods.c | file | annotate | diff | comparison | revisions |
--- a/libidav/methods.c Tue Oct 13 16:10:58 2015 +0200 +++ b/libidav/methods.c Wed Oct 14 11:49:39 2015 +0200 @@ -49,8 +49,26 @@ curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPFIND"); struct curl_slist *headers = NULL; + + char *url = NULL; + curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); + if(url) { + size_t ulen = strlen(url); + if(ulen > 0) { + if(url[ulen-1] == '/') { + headers = curl_slist_append(headers, "Depth: 1"); + } else { + headers = curl_slist_append(headers, "Depth: 0"); + } + } else { + return CURLE_URL_MALFORMAT; + } + } else { + return CURLE_URL_MALFORMAT; + } + headers = curl_slist_append(headers, "Content-Type: text/xml"); - headers = curl_slist_append(headers, "Depth: 1"); + curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(handle, CURLOPT_UPLOAD, 1);