libidav/jmap_methods.c

branch
dav-2
changeset 927
0bcf3d69b37a
parent 926
8470d5aac30e
--- a/libidav/jmap_methods.c	Thu Jul 09 22:07:33 2026 +0200
+++ b/libidav/jmap_methods.c	Fri Jul 10 17:56:21 2026 +0200
@@ -52,17 +52,25 @@
     curl_easy_setopt(sn->handle, CURLOPT_URL, sn->apiUrl);
     
     curl_easy_setopt(sn->handle, CURLOPT_POST, 1L);
-    curl_easy_setopt(sn->handle, CURLOPT_READFUNCTION, cxBufferRead);
-    curl_easy_setopt(sn->handle, CURLOPT_SEEKFUNCTION, cxBufferSeek);
-    curl_easy_setopt(sn->handle, CURLOPT_READDATA, request);
-    curl_easy_setopt(sn->handle, CURLOPT_SEEKDATA, request);
-    curl_easy_setopt(sn->handle, CURLOPT_INFILESIZE, request->size);
+    //curl_easy_setopt(sn->handle, CURLOPT_READFUNCTION, cxBufferRead);
+    //curl_easy_setopt(sn->handle, CURLOPT_SEEKFUNCTION, cxBufferSeek);
+    //curl_easy_setopt(sn->handle, CURLOPT_READDATA, request);
+    //curl_easy_setopt(sn->handle, CURLOPT_SEEKDATA, request);
+    //curl_easy_setopt(sn->handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)request->size);
+    curl_easy_setopt(sn->handle, CURLOPT_POSTFIELDSIZE, request->size);
+    curl_easy_setopt(sn->handle, CURLOPT_POSTFIELDS, request->space);
     
     CxBuffer *response = cxBufferCreate(NULL, NULL, 4096, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_FREE_CONTENTS);
     curl_easy_setopt(sn->handle, CURLOPT_WRITEFUNCTION, cxBufferWrite);
     curl_easy_setopt(sn->handle, CURLOPT_WRITEDATA, response);
     
+    struct curl_slist *headers = NULL;
+    headers = curl_slist_append(headers, "Content-Type: application/json");
+    headers = curl_slist_append(headers, "Accept: */*");
+    curl_easy_setopt(sn->handle, CURLOPT_HTTPHEADER, headers);
+    
     CURLcode ret = curl_easy_perform(sn->handle);
+    curl_slist_free_all(headers);
     long http_status;
     curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status);
     CxJsonValue *json = NULL;

mercurial