61 |
61 |
62 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
62 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
63 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
63 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
64 |
64 |
65 ucx_buffer_seek(request, 0, SEEK_SET); |
65 ucx_buffer_seek(request, 0, SEEK_SET); |
66 return curl_easy_perform(handle); |
66 CURLcode ret = curl_easy_perform(handle); |
|
67 curl_slist_free_all(headers); |
|
68 return ret; |
67 } |
69 } |
68 |
70 |
69 UcxBuffer* create_allprop_propfind_request() { |
71 UcxBuffer* create_allprop_propfind_request() { |
70 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
72 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
71 sstr_t s; |
73 sstr_t s; |
186 |
188 |
187 // end |
189 // end |
188 s = S("</D:prop>\n</D:propfind>\n"); |
190 s = S("</D:prop>\n</D:propfind>\n"); |
189 ucx_buffer_write(s.ptr, 1, s.length, buf); |
191 ucx_buffer_write(s.ptr, 1, s.length, buf); |
190 |
192 |
|
193 ucx_map_free(namespaces); |
191 return buf; |
194 return buf; |
192 } |
195 } |
193 |
196 |
194 UcxBuffer* create_basic_propfind_request() { |
197 UcxBuffer* create_basic_propfind_request() { |
195 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
198 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
246 if(node->type == XML_ELEMENT_NODE) { |
249 if(node->type == XML_ELEMENT_NODE) { |
247 if(xstreq(node->name, "response")) { |
250 if(xstreq(node->name, "response")) { |
248 parse_response_tag(root, node, cond, len); |
251 parse_response_tag(root, node, cond, len); |
249 } |
252 } |
250 } |
253 } |
251 |
|
252 node = node->next; |
254 node = node->next; |
253 } |
255 } |
|
256 xmlFreeDoc(doc); |
254 |
257 |
255 return root; |
258 return root; |
256 } |
259 } |
257 |
260 |
258 int parse_response_tag(DavResource *resource, xmlNode *node, DavQOp *cond, size_t clen) { |
261 int parse_response_tag(DavResource *resource, xmlNode *node, DavQOp *cond, size_t clen) { |
393 char *text = util_xml_get_text(prop); |
396 char *text = util_xml_get_text(prop); |
394 if(text) { |
397 if(text) { |
395 resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, text); |
398 resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, text); |
396 } |
399 } |
397 } |
400 } |
|
401 ucx_list_free(properties); |
398 |
402 |
399 set_davprops(res); |
403 set_davprops(res); |
400 if(res != resource) { |
404 if(res != resource) { |
401 if(clen > 0) { |
405 if(clen > 0) { |
402 if(!condition_eval(res, cond, clen)) { |
406 if(!condition_eval(res, cond, clen)) { |
448 |
452 |
449 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
453 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write); |
450 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
454 curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
451 |
455 |
452 ucx_buffer_seek(request, 0, SEEK_SET); |
456 ucx_buffer_seek(request, 0, SEEK_SET); |
453 return curl_easy_perform(handle); |
457 CURLcode ret = curl_easy_perform(handle); |
|
458 curl_slist_free_all(headers); |
|
459 return ret; |
454 } |
460 } |
455 |
461 |
456 UcxBuffer* create_proppatch_request(DavResourceData *data) { |
462 UcxBuffer* create_proppatch_request(DavResourceData *data) { |
457 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
463 UcxBuffer *buf = ucx_buffer_new(NULL, 512, 0); |
458 sstr_t s; |
464 sstr_t s; |
617 buf->size = length; |
623 buf->size = length; |
618 data = buf; |
624 data = buf; |
619 read_func = (dav_read_func)ucx_buffer_read; |
625 read_func = (dav_read_func)ucx_buffer_read; |
620 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
626 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
621 } else if(length == 0) { |
627 } else if(length == 0) { |
622 struct curl_slist *headers = NULL; |
|
623 headers = curl_slist_append(headers, "Transfer-Encoding: chunked"); |
628 headers = curl_slist_append(headers, "Transfer-Encoding: chunked"); |
624 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)1); |
629 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)1); |
625 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
630 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
626 } else { |
631 } else { |
627 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
632 curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
632 |
637 |
633 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
638 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
634 curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
639 curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
635 |
640 |
636 CURLcode ret = curl_easy_perform(handle); |
641 CURLcode ret = curl_easy_perform(handle); |
|
642 curl_slist_free_all(headers); |
637 if(buf) { |
643 if(buf) { |
638 ucx_buffer_free(buf); |
644 ucx_buffer_free(buf); |
639 } |
645 } |
640 return ret; |
646 return ret; |
641 } |
647 } |