libidav/methods.c

changeset 223
cbbdf207e67e
parent 208
1fb26aca5093
child 225
a297c2e28fa1
equal deleted inserted replaced
222:7b73058d782e 223:cbbdf207e67e
844 } 844 }
845 845
846 s = S("</D:propertyupdate>\n"); 846 s = S("</D:propertyupdate>\n");
847 ucx_buffer_write(s.ptr, 1, s.length, buf); 847 ucx_buffer_write(s.ptr, 1, s.length, buf);
848 848
849 // TODO: cleanup namespace map 849 // cleanup namespace map
850 ucx_map_free_content(namespaces, free);
851 ucx_map_free(namespaces);
850 852
851 return buf; 853 return buf;
852 } 854 }
853 855
854 UcxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, char *name, char *hash) { 856 UcxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, char *name, char *hash) {
898 900
899 static size_t dummy_write(void *buf, size_t s, size_t n, void *data) { 901 static size_t dummy_write(void *buf, size_t s, size_t n, void *data) {
900 return s*n; 902 return s*n;
901 } 903 }
902 904
903 CURLcode do_put_request(CURL *handle, char *lock, void *data, dav_read_func read_func, size_t length) { 905 CURLcode do_put_request(CURL *handle, char *lock, DavBool create, void *data, dav_read_func read_func, size_t length) {
904 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); 906 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL);
905 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); 907 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L);
906 908
907 // clear headers 909 // clear headers
908 struct curl_slist *headers = NULL; 910 struct curl_slist *headers = NULL;
909 if(lock) { 911 if(lock) {
910 char *url = NULL; 912 char *url = NULL;
911 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); 913 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url);
912 char *ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr; 914 char *ltheader = NULL;
915 if(create) {
916 url = util_parent_path(url);
917 ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr;
918 free(url);
919 } else {
920 ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr;
921 }
913 headers = curl_slist_append(headers, ltheader); 922 headers = curl_slist_append(headers, ltheader);
914 free(ltheader); 923 free(ltheader);
915 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); 924 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
916 } 925 }
917 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); 926 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
940 CURLcode ret = curl_easy_perform(handle); 949 CURLcode ret = curl_easy_perform(handle);
941 curl_slist_free_all(headers); 950 curl_slist_free_all(headers);
942 if(buf) { 951 if(buf) {
943 ucx_buffer_free(buf); 952 ucx_buffer_free(buf);
944 } 953 }
954
945 return ret; 955 return ret;
946 } 956 }
947 957
948 CURLcode do_delete_request(CURL *handle, char *lock, UcxBuffer *response) { 958 CURLcode do_delete_request(CURL *handle, char *lock, UcxBuffer *response) {
949 struct curl_slist *headers = NULL; 959 struct curl_slist *headers = NULL;
972 CURLcode do_mkcol_request(CURL *handle, char *lock) { 982 CURLcode do_mkcol_request(CURL *handle, char *lock) {
973 struct curl_slist *headers = NULL; 983 struct curl_slist *headers = NULL;
974 if(lock) { 984 if(lock) {
975 char *url = NULL; 985 char *url = NULL;
976 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); 986 curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url);
987 url = util_parent_path(url);
977 char *ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr; 988 char *ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr;
989 free(url);
978 headers = curl_slist_append(headers, ltheader); 990 headers = curl_slist_append(headers, ltheader);
979 free(ltheader); 991 free(ltheader);
980 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL); 992 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL);
981 } else { 993 } else {
982 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL); 994 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL);

mercurial