libidav/methods.c

changeset 354
067ea2315a8a
parent 331
9ca1e4706acc
child 361
b6f2462ee055
--- a/libidav/methods.c	Tue Dec 12 23:58:54 2017 +0100
+++ b/libidav/methods.c	Mon Dec 18 11:56:11 2017 +0100
@@ -43,10 +43,11 @@
 /* ----------------------------- PROPFIND ----------------------------- */
 
 CURLcode do_propfind_request(
-        CURL *handle,
+        DavSession *sn,
         UcxBuffer *request,
         UcxBuffer *response)
 {
+    CURL *handle = sn->handle;
     curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
     
     // always try to get information about possible children
@@ -81,7 +82,7 @@
         // reset buffers and perform request
         request->pos = 0;
         response->size = response->pos = 0;
-        ret = curl_easy_perform(handle);
+        ret = dav_session_curl_perform_buf(sn, request, response, NULL);
         curl_slist_free_all(headers);
         headers = NULL;
         
@@ -709,11 +710,12 @@
 /* ----------------------------- PROPPATCH ----------------------------- */
 
 CURLcode do_proppatch_request(
-        CURL *handle,
+        DavSession *sn,
         char *lock,
         UcxBuffer *request,
         UcxBuffer *response)
 {  
+    CURL *handle = sn->handle;
     curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPPATCH");
     
     struct curl_slist *headers = NULL;
@@ -737,7 +739,7 @@
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, response);
     
     ucx_buffer_seek(request, 0, SEEK_SET);
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform_buf(sn, request, response, NULL);
     curl_slist_free_all(headers);
     return ret;
 }
@@ -915,7 +917,8 @@
     return s*n;
 }
 
-CURLcode do_put_request(CURL *handle, char *lock, DavBool create, void *data, dav_read_func read_func, size_t length) {
+CURLcode do_put_request(DavSession *sn, char *lock, DavBool create, void *data, dav_read_func read_func, size_t length) {
+    CURL *handle = sn->handle;
     curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL);
     curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L);
     
@@ -959,7 +962,7 @@
     curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write);
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL);
     
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform(sn, NULL);
     curl_slist_free_all(headers);
     if(buf) {
         ucx_buffer_free(buf);
@@ -968,7 +971,8 @@
     return ret;
 }
 
-CURLcode do_delete_request(CURL *handle, char *lock, UcxBuffer *response) { 
+CURLcode do_delete_request(DavSession *sn, char *lock, UcxBuffer *response) { 
+    CURL *handle = sn->handle;
     struct curl_slist *headers = NULL;
     if(lock) {
         char *url = NULL;
@@ -987,12 +991,13 @@
     curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write);
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, response);
     
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform(sn, NULL);
     curl_slist_free_all(headers);
     return ret;
 }
 
-CURLcode do_mkcol_request(CURL *handle, char *lock) {
+CURLcode do_mkcol_request(DavSession *sn, char *lock) {
+    CURL *handle = sn->handle;
     struct curl_slist *headers = NULL;
     if(lock) {
         char *url = NULL;
@@ -1014,13 +1019,14 @@
     curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write);
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL);
     
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform(sn, NULL);
     curl_slist_free_all(headers);
     return ret;
 }
 
 
-CURLcode do_head_request(CURL *handle) {
+CURLcode do_head_request(DavSession *sn) {
+    CURL *handle = sn->handle;
     curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "HEAD");
     curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L);
     curl_easy_setopt(handle, CURLOPT_NOBODY, 1L);
@@ -1032,13 +1038,14 @@
     curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write);
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL);
     
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform(sn, NULL);
     curl_easy_setopt(handle, CURLOPT_NOBODY, 0L);
     return ret;
 }
 
 
-CURLcode do_copy_move_request(CURL *handle, char *dest, char *lock, DavBool copy, DavBool override) { 
+CURLcode do_copy_move_request(DavSession *sn, char *dest, char *lock, DavBool copy, DavBool override) { 
+    CURL *handle = sn->handle;
     if(copy) {
         curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "COPY");
     } else {
@@ -1068,7 +1075,7 @@
     }
     curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
     
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform(sn, NULL);
     free(deststr.ptr);
     curl_slist_free_all(headers);
     headers = NULL;
@@ -1156,7 +1163,8 @@
     return ret;
 }
 
-CURLcode do_lock_request(CURL *handle, UcxBuffer *request, UcxBuffer *response, time_t timeout) { 
+CURLcode do_lock_request(DavSession *sn, UcxBuffer *request, UcxBuffer *response, time_t timeout) { 
+    CURL *handle = sn->handle;
     curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "LOCK");  
     curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L);
     request->pos = 0;
@@ -1184,7 +1192,7 @@
     curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ucx_buffer_write);
     curl_easy_setopt(handle, CURLOPT_WRITEDATA, response);
     
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform_buf(sn, request, response, NULL);
     
     if(headers) {
         curl_slist_free_all(headers);
@@ -1193,7 +1201,8 @@
     return ret;
 }
 
-CURLcode do_unlock_request(CURL *handle, char *locktoken) {   
+CURLcode do_unlock_request(DavSession *sn, char *locktoken) {   
+    CURL *handle = sn->handle;
     curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "UNLOCK");
     curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L);
     
@@ -1205,7 +1214,7 @@
     struct curl_slist *headers = curl_slist_append(NULL, ltheader.ptr);
     curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
     
-    CURLcode ret = curl_easy_perform(handle);
+    CURLcode ret = dav_session_curl_perform(sn, NULL);
     curl_slist_free_all(headers);
     free(ltheader.ptr);
     

mercurial