reimplement dav_exists by using dav_load_prop feature/dav-edit

Sat, 28 Mar 2020 16:37:40 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 28 Mar 2020 16:37:40 +0100
branch
feature/dav-edit
changeset 713
a1c36a6410f6
parent 712
c62af832a0e2
child 714
10a5d6ce0906

reimplement dav_exists by using dav_load_prop

libidav/resource.c file | annotate | diff | comparison | revisions
--- a/libidav/resource.c	Sat Mar 28 16:28:52 2020 +0100
+++ b/libidav/resource.c	Sat Mar 28 16:37:40 2020 +0100
@@ -1267,21 +1267,11 @@
 }
 
 int dav_exists(DavResource *res) {
-    // TODO: reimplement with PROPFIND
-    
-    DavSession *sn = res->session;
-    CURL *handle = sn->handle;
-    util_set_url(sn, dav_resource_get_href(res));
-    
-    CURLcode ret = do_head_request(sn);
-    long status = 0;
-    curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
-    if(ret == CURLE_OK && (status >= 200 && status < 300)) {
+    if(!dav_load_prop(res, NULL, 0)) {
         res->exists = 1;
         return 1;
     } else {
-        dav_session_set_error(sn, ret, status);
-        if(status == 404) {
+        if(res->session->error == DAV_NOT_FOUND) {
             res->exists = 0;
         }
         return 0;

mercurial