444 |
444 |
445 return ret; |
445 return ret; |
446 } |
446 } |
447 |
447 |
448 int webdav_mkcol(pblock *pb, Session *sn, Request *rq) { |
448 int webdav_mkcol(pblock *pb, Session *sn, Request *rq) { |
449 UcxBuffer *reqbuf; |
449 WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE); |
450 VFSContext *vfs; |
450 if(!op) { |
451 char *path; |
|
452 |
|
453 if(webdav_init_vfs_op(sn, rq, &reqbuf, &vfs, &path)) { |
|
454 return REQ_ABORTED; |
451 return REQ_ABORTED; |
455 } |
452 } |
456 |
453 |
457 int ret = REQ_PROCEED; |
454 int ret = webdav_vfs_op_do(op, WEBDAV_VFS_MKDIR); |
458 if(vfs_mkdir(vfs, path)) { |
455 |
459 protocol_status(sn, rq, util_errno2status(vfs->vfs_errno), NULL); |
|
460 return REQ_ABORTED; |
|
461 } |
|
462 |
|
463 protocol_status(sn, rq, 201, NULL); |
|
464 |
|
465 // cleanup and return |
|
466 if(reqbuf) { |
|
467 ucx_buffer_free(reqbuf); |
|
468 } |
|
469 return ret; |
456 return ret; |
470 } |
457 } |
471 |
458 |
472 int webdav_post(pblock *pb, Session *sn, Request *rq) { |
459 int webdav_post(pblock *pb, Session *sn, Request *rq) { |
473 return REQ_ABORTED; |
460 return REQ_ABORTED; |
480 const char *path) |
467 const char *path) |
481 { |
468 { |
482 |
469 |
483 } |
470 } |
484 |
471 |
485 int webdav_delete(pblock *pb, Session *sn, Request *rq) { |
472 int webdav_delete(pblock *pb, Session *sn, Request *rq) { |
486 UcxBuffer *reqbuf; |
473 WebdavVFSOperation *op = webdav_vfs_op(sn, rq, rq->davCollection, TRUE); |
487 VFSContext *vfs; |
474 if(!op) { |
488 char *path; |
|
489 |
|
490 if(webdav_init_vfs_op(sn, rq, &reqbuf, &vfs, &path)) { |
|
491 return REQ_ABORTED; |
475 return REQ_ABORTED; |
492 } |
476 } |
493 |
477 |
494 int ret = REQ_PROCEED; |
478 int ret = webdav_vfs_op_do(op, WEBDAV_VFS_MKDIR); |
495 |
479 |
496 // TODO |
|
497 |
|
498 if(ret == REQ_PROCEED) { |
|
499 protocol_status(sn, rq, 200, NULL); |
|
500 } |
|
501 |
|
502 // cleanup and return |
|
503 if(reqbuf) { |
|
504 ucx_buffer_free(reqbuf); |
|
505 } |
|
506 return ret; |
480 return ret; |
507 } |
481 } |
508 |
482 |
509 int webdav_put(pblock *pb, Session *sn, Request *rq) { |
483 int webdav_put(pblock *pb, Session *sn, Request *rq) { |
510 return REQ_ABORTED; |
484 return REQ_ABORTED; |
533 int webdav_acl(pblock *pb, Session *sn, Request *rq) { |
507 int webdav_acl(pblock *pb, Session *sn, Request *rq) { |
534 return REQ_ABORTED; |
508 return REQ_ABORTED; |
535 } |
509 } |
536 |
510 |
537 |
511 |
538 int webdav_init_vfs_op( |
|
539 Session *sn, |
|
540 Request *rq, |
|
541 UcxBuffer **out_reqbuf, |
|
542 VFSContext **out_vfs, |
|
543 char **out_path) |
|
544 { |
|
545 *out_reqbuf = NULL; |
|
546 *out_vfs = NULL; |
|
547 *out_path = NULL; |
|
548 |
|
549 // create VFS context |
|
550 VFSContext *vfs = vfs_request_context(sn, rq); |
|
551 if(!vfs) { |
|
552 return REQ_ABORTED; |
|
553 } |
|
554 |
|
555 // read request body, if it exists |
|
556 char *expect = pblock_findkeyval(pb_key_expect, rq->headers); |
|
557 if(expect) { |
|
558 if(!strcasecmp(expect, "100-continue")) { |
|
559 if(http_send_continue(sn)) { |
|
560 return REQ_ABORTED; |
|
561 } |
|
562 } |
|
563 } |
|
564 |
|
565 UcxBuffer *reqbody = NULL; |
|
566 if(sn->inbuf) { |
|
567 reqbody = rqbody2buffer(sn, rq); |
|
568 if(!reqbody) { |
|
569 return REQ_ABORTED; |
|
570 } |
|
571 } |
|
572 |
|
573 // requested uri and path |
|
574 char *path = pblock_findkeyval(pb_key_path, rq->vars); |
|
575 |
|
576 *out_reqbuf = reqbody; |
|
577 *out_vfs = vfs; |
|
578 *out_path = path; |
|
579 |
|
580 return REQ_PROCEED; |
|
581 } |
|
582 |
512 |
583 /* ------------------------ default webdav backend ------------------------ */ |
513 /* ------------------------ default webdav backend ------------------------ */ |
584 |
514 |
585 int default_propfind_init( |
515 int default_propfind_init( |
586 WebdavPropfindRequest *rq, |
516 WebdavPropfindRequest *rq, |