Wed, 02 Nov 2022 18:38:40 +0100
improve error handling in webdav_proppatch
src/server/daemon/sessionhandler.c | file | annotate | diff | comparison | revisions | |
src/server/webdav/webdav.c | file | annotate | diff | comparison | revisions |
--- a/src/server/daemon/sessionhandler.c Wed Nov 02 18:21:58 2022 +0100 +++ b/src/server/daemon/sessionhandler.c Wed Nov 02 18:38:40 2022 +0100 @@ -439,7 +439,6 @@ int r = handle_request(request, NULL, h); if(r != 0) { - // TODO: error message connection_destroy(request->connection); }
--- a/src/server/webdav/webdav.c Wed Nov 02 18:21:58 2022 +0100 +++ b/src/server/webdav/webdav.c Wed Nov 02 18:38:40 2022 +0100 @@ -449,6 +449,19 @@ } +static const char* proppatch_error2str(int error) { + switch(error) { + case PROPPATCH_PARSER_OK: return "ok"; + case PROPPATCH_PARSER_NO_PROPERTYUPDATE: return "no property update"; + case PROPPATCH_PARSER_NO_PROPERTIES: return "no properties"; + case PROPPATCH_PARSER_INVALID_REQUEST: return "invalid proppatch request"; + case PROPPATCH_PARSER_DUPLICATE: return "proppatch property duplicate"; + case PROPPATCH_PARSER_OOM: return "OOM"; + case PROPPATCH_PARSER_ERROR: return "proppatch parser error"; + } + return "error"; +} + int webdav_proppatch(pblock *pb, Session *sn, Request *rq) { char *expect = pblock_findkeyval(pb_key_expect, rq->headers); if(expect) { @@ -461,6 +474,7 @@ UcxBuffer *reqbody = rqbody2buffer(sn, rq); if(!reqbody) { + // most likely OOM return REQ_ABORTED; } @@ -473,10 +487,8 @@ &error); ucx_buffer_free(reqbody); if(!proppatch) { - switch(error) { - // TODO: handle all errors - default: return REQ_ABORTED; - } + log_ereport(LOG_FAILURE, "webdav-proppatch: %s", proppatch_error2str(error)); + return REQ_ABORTED; } WebdavBackend *dav = rq->davCollection ? @@ -510,15 +522,17 @@ // Execute proppatch if(webdav_op_proppatch(op, uri, path)) { + log_ereport(LOG_FAILURE, "webdav-proppatch: proppatch operation failed"); ret = REQ_ABORTED; } // send response - if(ret == REQ_PROCEED && multistatus_send(ms, sn->csd)) { - ret = REQ_ABORTED; - // TODO: log error + if(ret == REQ_PROCEED) { + if(multistatus_send(ms, sn->csd)) { + log_ereport(LOG_FAILURE, "webdav-proppatch: multistatus_send failed"); + } } else { - // TODO: error response + protocol_status(sn, rq, 500, NULL); } // cleanup