src/server/webdav/webdav.c

branch
webdav
changeset 242
c337a7ac82a8
parent 241
4adad7faf452
child 243
1a29b1d8d9d8
equal deleted inserted replaced
241:4adad7faf452 242:c337a7ac82a8
295 if(webdav_op_propfind_finish(op)) { 295 if(webdav_op_propfind_finish(op)) {
296 // TODO: log error 296 // TODO: log error
297 ret = REQ_ABORTED; 297 ret = REQ_ABORTED;
298 } 298 }
299 299
300 // cleanup
301 xmlFreeDoc(propfind->doc);
302
300 return ret; 303 return ret;
301 } 304 }
302 305
303 /* 306 /*
304 * Initializes Backend Chain 307 * Initializes Backend Chain
361 return REQ_PROCEED; 364 return REQ_PROCEED;
362 } 365 }
363 366
364 367
365 int webdav_proppatch(pblock *pb, Session *sn, Request *rq) { 368 int webdav_proppatch(pblock *pb, Session *sn, Request *rq) {
366 return REQ_ABORTED; 369 char *expect = pblock_findkeyval(pb_key_expect, rq->headers);
370 if(expect) {
371 if(!strcasecmp(expect, "100-continue")) {
372 if(http_send_continue(sn)) {
373 return REQ_ABORTED;
374 }
375 }
376 }
377
378 UcxBuffer *reqbody = rqbody2buffer(sn, rq);
379 if(!reqbody) {
380 return REQ_ABORTED;
381 }
382
383 int error = 0;
384 WebdavProppatchRequest *proppatch = proppatch_parse(
385 sn,
386 rq,
387 reqbody->space,
388 reqbody->size,
389 &error);
390 ucx_buffer_free(reqbody);
391 if(!proppatch) {
392 switch(error) {
393 // TODO: handle all errors
394 default: return REQ_ABORTED;
395 }
396 }
397
398 WebdavBackend *dav = rq->davCollection ?
399 rq->davCollection : &default_backend;
400
401 // requested uri and path
402 char *path = pblock_findkeyval(pb_key_path, rq->vars);
403 char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
404
405 // The multistatus response object contains responses for all
406 // requested resources. At the end the Multistatus object will be
407 // serialized to xml
408 Multistatus *ms = multistatus_response(sn, rq);
409 if(!ms) {
410 return REQ_ABORTED;
411 }
412 ms->proppatch = TRUE;
413
414 // WebdavResponse is the public interface used by Backends
415 // for adding resources to the response
416 WebdavResponse *response = (WebdavResponse*)ms;
417
418 WebdavOperation *op = webdav_create_proppatch_operation(
419 sn,
420 rq,
421 dav,
422 proppatch,
423 response);
424
425 int ret = REQ_PROCEED;
426
427 // Execute proppatch
428 if(webdav_op_proppatch(op, uri, path)) {
429 ret = REQ_ABORTED;
430 }
431
432 // send response
433 if(ret == REQ_PROCEED && multistatus_send(ms, sn->csd)) {
434 ret = REQ_ABORTED;
435 // TODO: log error
436 } else {
437 // TODO: error response
438 }
439
440 // cleanup
441 xmlFreeDoc(proppatch->doc);
442
443 return ret;
367 } 444 }
368 445
369 int webdav_mkcol(pblock *pb, Session *sn, Request *rq) { 446 int webdav_mkcol(pblock *pb, Session *sn, Request *rq) {
370 return REQ_ABORTED; 447 return REQ_ABORTED;
371 } 448 }

mercurial