2 * Handles GroupDAV DELETE requests.
4 * Copyright (c) 2005-2012 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include "webserver.h"
21 * The pathname is always going to be /groupdav/room_name/euid
27 long dav_msgnum = (-1);
30 StrBuf *dav_roomname = NewStrBuf();
32 /* Now extract the message euid */
33 n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
34 extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
35 StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
37 ///* What's left is the room name. Remove trailing slashes. */
38 //len = StrLength(WCC->Hdr->HR.ReqLine);
39 //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
40 // StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
42 //StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
44 /* Go to the correct room. */
45 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
46 gotoroom(dav_roomname);
48 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
49 hprintf("HTTP/1.1 404 not found\r\n");
51 hprintf("Content-Length: 0\r\n\r\n");
54 FreeStrBuf(&dav_roomname);
58 dav_msgnum = locate_message_by_uid(dav_uid);
61 * If no item exists with the requested uid ... simple error.
63 if (dav_msgnum < 0L) {
64 hprintf("HTTP/1.1 404 Not Found\r\n");
66 hprintf("Content-Length: 0\r\n\r\n");
69 FreeStrBuf(&dav_roomname);
74 * It's there ... check the ETag and make sure it matches
77 if (StrLength(WCC->Hdr->HR.dav_ifmatch) > 0) {
78 if (StrTol(WCC->Hdr->HR.dav_ifmatch) != dav_msgnum) {
79 hprintf("HTTP/1.1 412 Precondition Failed\r\n");
81 hprintf("Content-Length: 0\r\n\r\n");
84 FreeStrBuf(&dav_roomname);
90 * Ok, attempt to delete the item.
92 serv_printf("DELE %ld", dav_msgnum);
93 serv_getln(buf, sizeof buf);
95 hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
97 hprintf("Content-Length: 0\r\n\r\n");
102 hprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
103 dav_common_headers();
104 hprintf("Content-Length: 0\r\n\r\n");
108 FreeStrBuf(&dav_roomname);