libidav/resource.c

changeset 205
bf756f6c3581
parent 186
05d11fbcaeb3
child 207
de23f8881e9f
equal deleted inserted replaced
204:4f0207044837 205:bf756f6c3581
607 data->content, 607 data->content,
608 data->read, 608 data->read,
609 data->length); 609 data->length);
610 } 610 }
611 611
612 int status = 0; 612 long status = 0;
613 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &status); 613 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &status);
614 if(ret == CURLE_OK && (status >= 200 && status < 300)) { 614 if(ret == CURLE_OK && (status >= 200 && status < 300)) {
615 res->session->error = 0; 615 res->session->error = 0;
616 // cleanup node data 616 // cleanup node data
617 if(!data->read) { 617 if(!data->read) {
631 UcxBuffer *request = create_proppatch_request(data); 631 UcxBuffer *request = create_proppatch_request(data);
632 UcxBuffer *response = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); 632 UcxBuffer *response = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
633 //printf("request:\n%.*s\n\n", request->pos, request->space); 633 //printf("request:\n%.*s\n\n", request->pos, request->space);
634 634
635 CURLcode ret = do_proppatch_request(sn->handle, request, response); 635 CURLcode ret = do_proppatch_request(sn->handle, request, response);
636 int status = 0; 636 long status = 0;
637 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &status); 637 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &status);
638 if(ret == CURLE_OK && status == 207) { 638 if(ret == CURLE_OK && status == 207) {
639 //printf("%s\n", response->space); 639 //printf("%s\n", response->space);
640 // TODO: parse response 640 // TODO: parse response
641 // TODO: cleanup node data correctly 641 // TODO: cleanup node data correctly
688 hash = util_hexstr((unsigned char*)sha, 32); 688 hash = util_hexstr((unsigned char*)sha, 32);
689 689
690 aes_decrypter_close(dec); 690 aes_decrypter_close(dec);
691 } 691 }
692 692
693 int status = 0; 693 long status = 0;
694 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); 694 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
695 if(ret == CURLE_OK && (status >= 200 && status < 300)) { 695 if(ret == CURLE_OK && (status >= 200 && status < 300)) {
696 int verify_failed = 0; 696 int verify_failed = 0;
697 if(DAV_DECRYPT_CONTENT(sn) && key) { 697 if(DAV_DECRYPT_CONTENT(sn) && key) {
698 // try to verify the content 698 // try to verify the content
743 CURL *handle = res->session->handle; 743 CURL *handle = res->session->handle;
744 util_set_url(res->session, dav_resource_get_href(res)); 744 util_set_url(res->session, dav_resource_get_href(res));
745 745
746 UcxBuffer *response = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); 746 UcxBuffer *response = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND);
747 CURLcode ret = do_delete_request(handle, response); 747 CURLcode ret = do_delete_request(handle, response);
748 int status = 0; 748 long status = 0;
749 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); 749 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
750 if(ret == CURLE_OK && (status >= 200 && status < 300)) { 750 if(ret == CURLE_OK && (status >= 200 && status < 300)) {
751 res->session->error = DAV_OK; 751 res->session->error = DAV_OK;
752 752
753 // TODO: parse response 753 // TODO: parse response
761 } 761 }
762 762
763 static int create_ancestors(DavSession *sn, char *href, char *path) { 763 static int create_ancestors(DavSession *sn, char *href, char *path) {
764 CURL *handle = sn->handle; 764 CURL *handle = sn->handle;
765 CURLcode code; 765 CURLcode code;
766 int status = 0; 766 long status = 0;
767 int ret = 0; 767 int ret = 0;
768 768
769 if(strlen(path) <= 1) { 769 if(strlen(path) <= 1) {
770 return 0; 770 return 0;
771 } 771 }
818 if(res->iscollection) { 818 if(res->iscollection) {
819 code = do_mkcol_request(handle); 819 code = do_mkcol_request(handle);
820 } else { 820 } else {
821 code = do_put_request(handle, "", NULL, 0); 821 code = do_put_request(handle, "", NULL, 0);
822 } 822 }
823 int s = 0; 823 long s = 0;
824 curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &s); 824 curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &s);
825 *status = s; 825 *status = s;
826 if(code == CURLE_OK && (s >= 200 && s < 300)) { 826 if(code == CURLE_OK && (s >= 200 && s < 300)) {
827 sn->error = DAV_OK; 827 sn->error = DAV_OK;
828 // if the session has encrypted file names, add crypto infos 828 // if the session has encrypted file names, add crypto infos
860 DavSession *sn = res->session; 860 DavSession *sn = res->session;
861 CURL *handle = sn->handle; 861 CURL *handle = sn->handle;
862 util_set_url(sn, dav_resource_get_href(res)); 862 util_set_url(sn, dav_resource_get_href(res));
863 863
864 CURLcode ret = do_head_request(handle); 864 CURLcode ret = do_head_request(handle);
865 int status = 0; 865 long status = 0;
866 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); 866 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
867 if(ret == CURLE_OK && (status >= 200 && status < 300)) { 867 if(ret == CURLE_OK && (status >= 200 && status < 300)) {
868 return 1; 868 return 1;
869 } else { 869 } else {
870 dav_session_set_error(sn, ret, status); 870 dav_session_set_error(sn, ret, status);
877 CURL *handle = sn->handle; 877 CURL *handle = sn->handle;
878 util_set_url(sn, dav_resource_get_href(res)); 878 util_set_url(sn, dav_resource_get_href(res));
879 879
880 CURLcode ret = do_copy_move_request(handle, desturl, copy, override); 880 CURLcode ret = do_copy_move_request(handle, desturl, copy, override);
881 881
882 int status = 0; 882 long status = 0;
883 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); 883 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
884 if(ret == CURLE_OK && (status >= 200 && status < 300)) { 884 if(ret == CURLE_OK && (status >= 200 && status < 300)) {
885 return 0; 885 return 0;
886 } else { 886 } else {
887 dav_session_set_error(sn, ret, status); 887 dav_session_set_error(sn, ret, status);
933 UcxBuffer *response = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); 933 UcxBuffer *response = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
934 934
935 util_set_url(sn, href); 935 util_set_url(sn, href);
936 CURLcode ret = do_proppatch_request(sn->handle, request, response); 936 CURLcode ret = do_proppatch_request(sn->handle, request, response);
937 ucx_buffer_free(request); 937 ucx_buffer_free(request);
938 int status = 0; 938 long status = 0;
939 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &status); 939 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &status);
940 if(ret == CURLE_OK && status == 207) { 940 if(ret == CURLE_OK && status == 207) {
941 // TODO: parse response 941 // TODO: parse response
942 sn->error = DAV_OK; 942 sn->error = DAV_OK;
943 ucx_buffer_free(response); 943 ucx_buffer_free(response);

mercurial