158 } |
158 } |
159 |
159 |
160 |
160 |
161 DavResource* dav_get(DavSession *sn, char *path, char *properties) { |
161 DavResource* dav_get(DavSession *sn, char *path, char *properties) { |
162 CURL *handle = sn->handle; |
162 CURL *handle = sn->handle; |
163 char *href = dav_session_get_href(sn, path); |
163 DavResource *resource = dav_resource_new(sn, path); |
164 util_set_url(sn, href); |
164 util_set_url(sn, dav_resource_get_href(resource)); |
165 dav_session_free(sn, href); |
|
166 |
165 |
167 UcxList *proplist = NULL; |
166 UcxList *proplist = NULL; |
168 if(properties) { |
167 if(properties) { |
169 proplist = parse_properties_string(sn->context, sstr(properties)); |
168 proplist = parse_properties_string(sn->context, sstr(properties)); |
170 } |
169 } |
172 UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
171 UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
173 |
172 |
174 //fwrite(rqbuf->space, 1, rqbuf->size, stdout); |
173 //fwrite(rqbuf->space, 1, rqbuf->size, stdout); |
175 //printf("\n"); |
174 //printf("\n"); |
176 |
175 |
177 DavResource *resource = NULL; |
|
178 CURLcode ret = do_propfind_request(handle, rqbuf, rpbuf); |
176 CURLcode ret = do_propfind_request(handle, rqbuf, rpbuf); |
179 int status = 0; |
177 int status = 0; |
180 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
178 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
181 if(ret == CURLE_OK && status == 207) { |
179 if(ret == CURLE_OK && status == 207) { |
182 //printf("response\n%s\n", rpbuf->space); |
180 //printf("response\n%s\n", rpbuf->space); |
183 resource = parse_propfind_response(sn, NULL, rpbuf, NULL, 0); |
181 resource = parse_propfind_response(sn, resource, rpbuf, NULL, 0); |
184 sn->error = DAV_OK; |
182 sn->error = DAV_OK; |
185 } else { |
183 } else { |
186 dav_session_set_error(sn, ret, status); |
184 dav_session_set_error(sn, ret, status); |
|
185 dav_resource_free(resource); |
187 } |
186 } |
188 |
187 |
189 ucx_buffer_free(rqbuf); |
188 ucx_buffer_free(rqbuf); |
190 ucx_buffer_free(rpbuf); |
189 ucx_buffer_free(rpbuf); |
191 |
190 |