diff -r 712aca08da7f -r 0f678595d497 src/server/webdav/multistatus.c --- a/src/server/webdav/multistatus.c Tue Nov 01 15:59:28 2022 +0100 +++ b/src/server/webdav/multistatus.c Tue Nov 01 16:40:03 2022 +0100 @@ -155,23 +155,6 @@ writer_putc(out, ':'); writer_puts(out, sstr((char*)property->name)); - // check if the namespace is already defined - WSBool need_nsdef = TRUE; - WSNamespace *ns = ucx_map_cstr_get( - ms->namespaces, - (char*)property->namespace->prefix); - if(ns && !strcmp( - (const char*)ns->href, - (const char*)property->namespace->href)) - { - need_nsdef = FALSE; // prefix and href are the same, no need for nsdef - } - - // send definition for the element's namespace - if(need_nsdef) { - send_nsdef(property->namespace, out); - } - // send additional namespace definitions required for the value WebdavNSList *def = nsdef; while(def) { @@ -420,6 +403,62 @@ return 0; } +/* + * should only be called from msresponse_addproperty + * + * Adds a property to the error list with the specified statuscode + */ +static int msresponse_addproperror( + MSResponse *response, + WebdavProperty *property, + int statuscode) +{ + pool_handle_t *pool = response->multistatus->sn->pool; + UcxAllocator *a = session_get_allocator(response->multistatus->sn); + + response->resource.err++; + + // MSResponse contains a list of properties for each status code + // at first find the list for this status code + PropertyErrorList *errlist = NULL; + PropertyErrorList *list = response->errors; + PropertyErrorList *last = NULL; + while(list) { + if(list->status == statuscode) { + errlist = list; + break; + } + last = list; + list = list->next; + } + + if(!errlist) { + // no list available for this statuscode + PropertyErrorList *newelm = pool_malloc(pool, + sizeof(PropertyErrorList)); + if(!newelm) { + return 1; + } + newelm->begin = NULL; + newelm->end = NULL; + newelm->next = NULL; + newelm->status = statuscode; + + if(last) { + last->next = newelm; + } else { + response->errors = newelm; + } + errlist = newelm; + } + + // we have the list -> add the new element + if(webdav_plist_add(pool, &errlist->begin, &errlist->end, property)) { + return 1; + } + return 0; +} + int msresponse_addproperty( WebdavResource *res, WebdavProperty *property, @@ -564,57 +603,6 @@ return 0; } -int msresponse_addproperror( - MSResponse *response, - WebdavProperty *property, - int statuscode) -{ - pool_handle_t *pool = response->multistatus->sn->pool; - UcxAllocator *a = session_get_allocator(response->multistatus->sn); - - response->resource.err++; - - // MSResponse contains a list of properties for each status code - // at first find the list for this status code - PropertyErrorList *errlist = NULL; - PropertyErrorList *list = response->errors; - PropertyErrorList *last = NULL; - while(list) { - if(list->status == statuscode) { - errlist = list; - break; - } - last = list; - list = list->next; - } - - if(!errlist) { - // no list available for this statuscode - PropertyErrorList *newelm = pool_malloc(pool, - sizeof(PropertyErrorList)); - if(!newelm) { - return 1; - } - newelm->begin = NULL; - newelm->end = NULL; - newelm->next = NULL; - newelm->status = statuscode; - - if(last) { - last->next = newelm; - } else { - response->errors = newelm; - } - errlist = newelm; - } - - // we have the list -> add the new element - if(webdav_plist_add(pool, &errlist->begin, &errlist->end, property)) { - return 1; - } - return 0; -} - int msresponse_close(WebdavResource *res) { MSResponse *response = (MSResponse*)res; if(response->closing) { @@ -646,12 +634,12 @@ if(!ucx_map_sstr_get(response->properties, key)) { // property was not added to this response if(ms->proppatch) { - if(msresponse_addproperror(response, pl->property, 424)) { + if(msresponse_addproperty(res, pl->property, 424)) { ret = REQ_ABORTED; break; } } else { - if(msresponse_addproperror(response, pl->property, 404)) { + if(msresponse_addproperty(res, pl->property, 404)) { ret = REQ_ABORTED; break; } @@ -668,7 +656,7 @@ PropertyOkList *elm = response->plist_begin; PropertyOkList *nextelm; while(elm) { - if(msresponse_addproperror(response, elm->property, 424)) { + if(msresponse_addproperty(res, elm->property, 424)) { return 1; } nextelm = elm->next;