109 ucx_map_free(respheaders); |
109 ucx_map_free(respheaders); |
110 |
110 |
111 return ret; |
111 return ret; |
112 } |
112 } |
113 |
113 |
114 UcxBuffer* create_allprop_propfind_request() { |
114 UcxBuffer* create_allprop_propfind_request(void) { |
115 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOFREE); |
115 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOFREE); |
116 sstr_t s; |
116 sstr_t s; |
117 |
117 |
118 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
118 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
119 ucx_buffer_write(s.ptr, 1, s.length, buf); |
119 ucx_buffer_write(s.ptr, 1, s.length, buf); |
245 |
245 |
246 ucx_map_free(namespaces); |
246 ucx_map_free(namespaces); |
247 return buf; |
247 return buf; |
248 } |
248 } |
249 |
249 |
250 UcxBuffer* create_basic_propfind_request() { |
250 UcxBuffer* create_basic_propfind_request(void) { |
251 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
251 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
252 sstr_t s; |
252 sstr_t s; |
253 |
253 |
254 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
254 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
255 ucx_buffer_write(s.ptr, 1, s.length, buf); |
255 ucx_buffer_write(s.ptr, 1, s.length, buf); |
1075 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1075 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1076 return ret; |
1076 return ret; |
1077 } |
1077 } |
1078 |
1078 |
1079 |
1079 |
1080 UcxBuffer* create_lock_request() { |
1080 UcxBuffer* create_lock_request(void) { |
1081 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
1081 UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
1082 sstr_t s; |
1082 sstr_t s; |
1083 |
1083 |
1084 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
1084 s = S("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
1085 ucx_buffer_write(s.ptr, 1, s.length, buf); |
1085 ucx_buffer_write(s.ptr, 1, s.length, buf); |
1154 |
1154 |
1155 xmlFreeDoc(doc); |
1155 xmlFreeDoc(doc); |
1156 return ret; |
1156 return ret; |
1157 } |
1157 } |
1158 |
1158 |
1159 CURLcode do_lock_request(CURL *handle, UcxBuffer *request, UcxBuffer *response) { |
1159 CURLcode do_lock_request(CURL *handle, UcxBuffer *request, UcxBuffer *response, time_t timeout) { |
1160 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "LOCK"); |
1160 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "LOCK"); |
1161 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
1161 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
1162 request->pos = 0; |
1162 request->pos = 0; |
1163 |
1163 |
1164 // clear headers |
1164 // clear headers |
1165 struct curl_slist *headers = NULL; |
1165 struct curl_slist *headers = NULL; |
|
1166 |
|
1167 if(timeout != 0) { |
|
1168 sstr_t thdr; |
|
1169 if(timeout < 0) { |
|
1170 thdr = ucx_sprintf("%s", "Timeout: Infinite"); |
|
1171 } else { |
|
1172 thdr = ucx_sprintf("Timeout: Second-%u", (unsigned int)timeout); |
|
1173 } |
|
1174 headers = curl_slist_append(headers, thdr.ptr); |
|
1175 free(thdr.ptr); |
|
1176 } |
1166 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1177 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1167 |
1178 |
1168 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
1179 curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
1169 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
1180 curl_easy_setopt(handle, CURLOPT_READFUNCTION, ucx_buffer_read); |
1170 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
1181 curl_easy_setopt(handle, CURLOPT_READDATA, request); |
1173 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
1184 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
1174 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
1185 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
1175 |
1186 |
1176 CURLcode ret = curl_easy_perform(handle); |
1187 CURLcode ret = curl_easy_perform(handle); |
1177 |
1188 |
|
1189 if(headers) { |
|
1190 curl_slist_free_all(headers); |
|
1191 } |
|
1192 |
1178 return ret; |
1193 return ret; |
1179 } |
1194 } |
1180 |
1195 |
1181 CURLcode do_unlock_request(CURL *handle, char *locktoken) { |
1196 CURLcode do_unlock_request(CURL *handle, char *locktoken) { |
1182 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "UNLOCK"); |
1197 curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "UNLOCK"); |