added extra propfind request to dav_create

Mon, 19 Aug 2013 17:42:40 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 19 Aug 2013 17:42:40 +0200
changeset 25
29f77f1fdbf3
parent 24
a317202ae787
child 26
146171b57e69

added extra propfind request to dav_create

dav/webdav.c file | annotate | diff | comparison | revisions
--- a/dav/webdav.c	Mon Aug 19 17:10:22 2013 +0200
+++ b/dav/webdav.c	Mon Aug 19 17:42:40 2013 +0200
@@ -712,9 +712,44 @@
     curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
     if(ret == CURLE_OK && (status >= 200 && status < 300)) {
         res->session->error = DAV_OK;
-        return 0;
     } else {
         session_set_error(res->session, ret, status);
         return 1;
     }
+    
+    // do an minimal propfind request
+    UcxBuffer *rqbuf = create_propfind_request(NULL);
+    UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND);
+    
+    //fwrite(rpbuf->space, 1, rpbuf->size, stdout);
+    //printf("\n");
+    
+    ret = do_propfind_request(handle, rqbuf, rpbuf);
+    status = 0;
+    curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
+    if(ret == CURLE_OK && (status >= 200 && status < 300)) {
+        //printf("response\n%s\n", rpbuf->space);
+        // TODO: use parse_propfind_response()
+        xmlDoc *doc = xmlReadMemory(rpbuf->space, rpbuf->size, url, NULL, 0);
+        if(!doc) {
+            return 1;
+        }
+
+        xmlNode *xml_root = xmlDocGetRootElement(doc);
+        xmlNode *node = xml_root->children;
+        while(node) {
+            if(node->type == XML_ELEMENT_NODE) {
+                if(xstreq(node->name, "response")) {
+                    parse_response_tag(res, node);
+                }
+            }
+            node = node->next;
+        }
+        
+        set_davprops(res);
+        return 0;
+    } else {
+        session_set_error(sn, ret, status);
+        return 1;
+    }
 }

mercurial