src/server/webdav/multistatus.c

branch
webdav
changeset 217
8ed14d76db42
parent 211
2160585200ac
child 222
5f05e56cb8e2
equal deleted inserted replaced
216:ce2866ec97f6 217:8ed14d76db42
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 31
32 #include "../daemon/session.h" 32 #include "../daemon/session.h"
33 33
34 #include "operation.h"
35
34 #include "multistatus.h" 36 #include "multistatus.h"
35 37
36 #define MULTISTATUS_BUFFER_LENGTH 2048 38 #define MULTISTATUS_BUFFER_LENGTH 2048
37 39
38 Multistatus* multistatus_response(Session *sn, Request *rq) { 40 Multistatus* multistatus_response(Session *sn, Request *rq) {
264 return NULL; 266 return NULL;
265 } 267 }
266 ZERO(res, sizeof(MSResponse)); 268 ZERO(res, sizeof(MSResponse));
267 269
268 res->resource.addproperty = msresponse_addproperty; 270 res->resource.addproperty = msresponse_addproperty;
271 res->resource.close = msresponse_close;
269 272
270 res->multistatus = ms; 273 res->multistatus = ms;
271 res->errors = NULL; 274 res->errors = NULL;
272 res->end = 0; 275 res->resource.isclosed = 0;
276 res->closing = 0;
273 277
274 if(ms->current) { 278 if(ms->current) {
275 ms->current->end = 1; 279 if(!ms->current->resource.isclosed) {
280 msresponse_close((WebdavResource*)ms->current);
281 }
276 ms->current->next = res; 282 ms->current->next = res;
277 } else { 283 } else {
278 ms->first = res; 284 ms->first = res;
279 } 285 }
280 ms->current = res; 286 ms->current = res;
286 WebdavResource *res, 292 WebdavResource *res,
287 WebdavProperty *property, 293 WebdavProperty *property,
288 int status) 294 int status)
289 { 295 {
290 MSResponse *response = (MSResponse*)res; 296 MSResponse *response = (MSResponse*)res;
291 if(response->end) { 297 if(response->resource.isclosed) {
292 log_ereport( 298 log_ereport(
293 LOG_WARN, 299 LOG_WARN,
294 "%s", 300 "%s",
295 "webdav: cannot add property to closed response tag"); 301 "webdav: cannot add property to closed response tag");
296 return 0; 302 return 0;
387 if(!errlist->begin) { 393 if(!errlist->begin) {
388 errlist->begin = newlistelm; 394 errlist->begin = newlistelm;
389 } 395 }
390 return 0; 396 return 0;
391 } 397 }
398
399 int msresponse_close(WebdavResource *res) {
400 MSResponse *response = (MSResponse*)res;
401 if(response->closing) {
402 return 0; // close already in progress
403 }
404
405 int ret = REQ_PROCEED;
406 WebdavOperation *op = response->multistatus->response.op;
407 if(webdav_op_propfiond_close_resource(op, res)) {
408 ret = REQ_ABORTED;
409 }
410
411 response->resource.isclosed = TRUE;
412 response->closing = FALSE;
413 return ret;
414 }

mercurial