Tue, 05 Sep 2017 17:25:09 +0200
dav get-property shouldn't send an allprop propfind request
dav/main.c | file | annotate | diff | comparison | revisions | |
libidav/resource.c | file | annotate | diff | comparison | revisions | |
libidav/webdav.h | file | annotate | diff | comparison | revisions |
--- a/dav/main.c Tue Sep 05 16:03:48 2017 +0200 +++ b/dav/main.c Tue Sep 05 17:25:09 2017 +0200 @@ -1155,9 +1155,17 @@ char *namespace = cmd_getoption(a, "namespace"); char *property = a->argv[1]; + DavPropName propname; + if(namespace) { + propname.ns = namespace; + propname.name = property; + } else { + dav_get_property_namespace_str(ctx, property, &propname.ns, &propname.name); + } + DavResource *res = dav_resource_new(sn, path); - for(int i=0;i<2;i++) { - if(dav_load(res)) { + for(int i=0;i<2;i++) { + if(dav_load_prop(res, &propname, 1)) { if(i == 0 && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn, a)) { continue; } @@ -1167,9 +1175,7 @@ break; } - char *value = namespace ? - dav_get_property_ns(res, namespace, property) : - dav_get_property(res, property); + char *value = dav_get_property_ns(res, propname.ns, propname.name); if(!value) { fprintf(stderr, "Error: no property value.\n"); return -1;
--- a/libidav/resource.c Tue Sep 05 16:03:48 2017 +0200 +++ b/libidav/resource.c Tue Sep 05 17:25:09 2017 +0200 @@ -569,6 +569,31 @@ return ret; } +int dav_load_prop(DavResource *res, DavPropName *properties, size_t numprop) { + UcxMempool *mp = ucx_mempool_new(64); + + UcxList *proplist = NULL; + for(size_t i=0;i<numprop;i++) { + DavProperty *p = ucx_mempool_malloc(mp, sizeof(DavProperty)); + p->name = properties[i].name; + p->ns = ucx_mempool_malloc(mp, sizeof(DavNamespace)); + p->ns->name = properties[i].ns; + if(!strcmp(properties[i].ns, "DAV:")) { + p->ns->prefix = "D"; + } else { + p->ns->prefix = ucx_asprintf(mp->allocator, "x%d", i).ptr; + } + p->value = NULL; + proplist = ucx_list_append_a(mp->allocator, proplist, p); + } + + UcxBuffer *rqbuf = create_propfind_request(res->session, proplist); + int ret = dav_propfind(res->session, res, rqbuf); + ucx_buffer_free(rqbuf); + ucx_mempool_destroy(mp); + return ret; +} + int dav_store(DavResource *res) { DavSession *sn = res->session; DavResourceData *data = res->data;
--- a/libidav/webdav.h Tue Sep 05 16:03:48 2017 +0200 +++ b/libidav/webdav.h Tue Sep 05 17:25:09 2017 +0200 @@ -258,6 +258,7 @@ void dav_set_content_length(DavResource *res, size_t length); int dav_load(DavResource *res); +int dav_load_prop(DavResource *res, DavPropName *properties, size_t numprop); int dav_store(DavResource *res); int dav_get_content(DavResource *res, void *stream, dav_write_func write_func);