# HG changeset patch # User Olaf Wintermann # Date 1504625109 -7200 # Node ID 755b8198b0715f2ec9e341fe8e7fed95ac3283be # Parent 3cbe57eeaed188068030ddbb0ce54fcc16efcc8a dav get-property shouldn't send an allprop propfind request diff -r 3cbe57eeaed1 -r 755b8198b071 dav/main.c --- 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; diff -r 3cbe57eeaed1 -r 755b8198b071 libidav/resource.c --- 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;iname = 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; diff -r 3cbe57eeaed1 -r 755b8198b071 libidav/webdav.h --- 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);