479 |
479 |
480 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_func); |
480 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_func); |
481 curl_easy_setopt(handle, CURLOPT_WRITEDATA, stream); |
481 curl_easy_setopt(handle, CURLOPT_WRITEDATA, stream); |
482 |
482 |
483 CURLcode ret = curl_easy_perform(handle); |
483 CURLcode ret = curl_easy_perform(handle); |
484 |
|
485 int status = 0; |
484 int status = 0; |
486 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
485 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
487 if(ret == CURLE_OK && (status >= 200 && status < 300)) { |
486 if(ret == CURLE_OK && (status >= 200 && status < 300)) { |
488 res->session->error = DAV_OK; |
487 res->session->error = DAV_OK; |
489 return 0; |
488 return 0; |
491 session_set_error(res->session, ret, status); |
490 session_set_error(res->session, ret, status); |
492 return 1; |
491 return 1; |
493 } |
492 } |
494 } |
493 } |
495 |
494 |
|
495 int dav_delete(DavResource *res) { |
|
496 char *url = util_concat_path(res->session->base_url, res->path); |
|
497 CURL *handle = res->session->handle; |
|
498 curl_easy_setopt(handle, CURLOPT_URL, url); |
|
499 free(url); |
|
500 |
|
501 UcxBuffer *response = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
|
502 CURLcode ret = do_delete_request(handle, response); |
|
503 int status = 0; |
|
504 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
|
505 if(ret == CURLE_OK && (status >= 200 && status < 300)) { |
|
506 res->session->error = DAV_OK; |
|
507 |
|
508 // TODO: parse response |
|
509 // TODO: free res |
|
510 |
|
511 return 0; |
|
512 } else { |
|
513 session_set_error(res->session, ret, status); |
|
514 return 1; |
|
515 } |
|
516 } |