diff -r e59abb210584 -r a193c42fc809 src/server/webdav/webdav.c --- a/src/server/webdav/webdav.c Sat Feb 01 18:44:31 2020 +0100 +++ b/src/server/webdav/webdav.c Sun Feb 02 17:42:05 2020 +0100 @@ -446,26 +446,13 @@ } int webdav_mkcol(pblock *pb, Session *sn, Request *rq) { - UcxBuffer *reqbuf; - VFSContext *vfs; - char *path; - - if(webdav_init_vfs_op(sn, rq, &reqbuf, &vfs, &path)) { + WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE); + if(!op) { return REQ_ABORTED; } - int ret = REQ_PROCEED; - if(vfs_mkdir(vfs, path)) { - protocol_status(sn, rq, util_errno2status(vfs->vfs_errno), NULL); - return REQ_ABORTED; - } + int ret = webdav_vfs_op_do(op, WEBDAV_VFS_MKDIR); - protocol_status(sn, rq, 201, NULL); - - // cleanup and return - if(reqbuf) { - ucx_buffer_free(reqbuf); - } return ret; } @@ -482,27 +469,14 @@ } -int webdav_delete(pblock *pb, Session *sn, Request *rq) { - UcxBuffer *reqbuf; - VFSContext *vfs; - char *path; - - if(webdav_init_vfs_op(sn, rq, &reqbuf, &vfs, &path)) { +int webdav_delete(pblock *pb, Session *sn, Request *rq) { + WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE); + if(!op) { return REQ_ABORTED; } - int ret = REQ_PROCEED; - - // TODO + int ret = webdav_vfs_op_do(op, WEBDAV_VFS_MKDIR); - if(ret == REQ_PROCEED) { - protocol_status(sn, rq, 200, NULL); - } - - // cleanup and return - if(reqbuf) { - ucx_buffer_free(reqbuf); - } return ret; } @@ -535,50 +509,6 @@ } -int webdav_init_vfs_op( - Session *sn, - Request *rq, - UcxBuffer **out_reqbuf, - VFSContext **out_vfs, - char **out_path) -{ - *out_reqbuf = NULL; - *out_vfs = NULL; - *out_path = NULL; - - // create VFS context - VFSContext *vfs = vfs_request_context(sn, rq); - if(!vfs) { - return REQ_ABORTED; - } - - // read request body, if it exists - char *expect = pblock_findkeyval(pb_key_expect, rq->headers); - if(expect) { - if(!strcasecmp(expect, "100-continue")) { - if(http_send_continue(sn)) { - return REQ_ABORTED; - } - } - } - - UcxBuffer *reqbody = NULL; - if(sn->inbuf) { - reqbody = rqbody2buffer(sn, rq); - if(!reqbody) { - return REQ_ABORTED; - } - } - - // requested uri and path - char *path = pblock_findkeyval(pb_key_path, rq->vars); - - *out_reqbuf = reqbody; - *out_vfs = vfs; - *out_path = path; - - return REQ_PROCEED; -} /* ------------------------ default webdav backend ------------------------ */