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 } |