libidav/jmap_methods.c

branch
dav-2
changeset 927
0bcf3d69b37a
parent 926
8470d5aac30e
equal deleted inserted replaced
926:8470d5aac30e 927:0bcf3d69b37a
50 50
51 CxJsonValue* jm_do_api_request(JMAPSession *sn, CxBuffer *request) { 51 CxJsonValue* jm_do_api_request(JMAPSession *sn, CxBuffer *request) {
52 curl_easy_setopt(sn->handle, CURLOPT_URL, sn->apiUrl); 52 curl_easy_setopt(sn->handle, CURLOPT_URL, sn->apiUrl);
53 53
54 curl_easy_setopt(sn->handle, CURLOPT_POST, 1L); 54 curl_easy_setopt(sn->handle, CURLOPT_POST, 1L);
55 curl_easy_setopt(sn->handle, CURLOPT_READFUNCTION, cxBufferRead); 55 //curl_easy_setopt(sn->handle, CURLOPT_READFUNCTION, cxBufferRead);
56 curl_easy_setopt(sn->handle, CURLOPT_SEEKFUNCTION, cxBufferSeek); 56 //curl_easy_setopt(sn->handle, CURLOPT_SEEKFUNCTION, cxBufferSeek);
57 curl_easy_setopt(sn->handle, CURLOPT_READDATA, request); 57 //curl_easy_setopt(sn->handle, CURLOPT_READDATA, request);
58 curl_easy_setopt(sn->handle, CURLOPT_SEEKDATA, request); 58 //curl_easy_setopt(sn->handle, CURLOPT_SEEKDATA, request);
59 curl_easy_setopt(sn->handle, CURLOPT_INFILESIZE, request->size); 59 //curl_easy_setopt(sn->handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)request->size);
60 curl_easy_setopt(sn->handle, CURLOPT_POSTFIELDSIZE, request->size);
61 curl_easy_setopt(sn->handle, CURLOPT_POSTFIELDS, request->space);
60 62
61 CxBuffer *response = cxBufferCreate(NULL, NULL, 4096, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_FREE_CONTENTS); 63 CxBuffer *response = cxBufferCreate(NULL, NULL, 4096, CX_BUFFER_AUTO_EXTEND | CX_BUFFER_FREE_CONTENTS);
62 curl_easy_setopt(sn->handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); 64 curl_easy_setopt(sn->handle, CURLOPT_WRITEFUNCTION, cxBufferWrite);
63 curl_easy_setopt(sn->handle, CURLOPT_WRITEDATA, response); 65 curl_easy_setopt(sn->handle, CURLOPT_WRITEDATA, response);
64 66
67 struct curl_slist *headers = NULL;
68 headers = curl_slist_append(headers, "Content-Type: application/json");
69 headers = curl_slist_append(headers, "Accept: */*");
70 curl_easy_setopt(sn->handle, CURLOPT_HTTPHEADER, headers);
71
65 CURLcode ret = curl_easy_perform(sn->handle); 72 CURLcode ret = curl_easy_perform(sn->handle);
73 curl_slist_free_all(headers);
66 long http_status; 74 long http_status;
67 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status); 75 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status);
68 CxJsonValue *json = NULL; 76 CxJsonValue *json = NULL;
69 if(ret == CURLE_OK) { 77 if(ret == CURLE_OK) {
70 if(http_status >= 200 && http_status <= 299) { 78 if(http_status >= 200 && http_status <= 299) {

mercurial