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.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
22 #include "webserver.h"
27 * The pathname is always going to be /groupdav/room_name/euid
33 long dav_msgnum = (-1);
36 StrBuf *dav_roomname = NewStrBuf();
38 /* Now extract the message euid */
39 n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
40 extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
41 StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
43 ///* What's left is the room name. Remove trailing slashes. */
44 //len = StrLength(WCC->Hdr->HR.ReqLine);
45 //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
46 // StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
48 //StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
50 /* Go to the correct room. */
51 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
52 gotoroom(dav_roomname);
54 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
55 hprintf("HTTP/1.1 404 not found\r\n");
57 hprintf("Content-Length: 0\r\n\r\n");
60 FreeStrBuf(&dav_roomname);
64 dav_msgnum = locate_message_by_uid(dav_uid);
67 * If no item exists with the requested uid ... simple error.
69 if (dav_msgnum < 0L) {
70 hprintf("HTTP/1.1 404 Not Found\r\n");
72 hprintf("Content-Length: 0\r\n\r\n");
75 FreeStrBuf(&dav_roomname);
80 * It's there ... check the ETag and make sure it matches
83 if (StrLength(WCC->Hdr->HR.dav_ifmatch) > 0) {
84 if (StrTol(WCC->Hdr->HR.dav_ifmatch) != dav_msgnum) {
85 hprintf("HTTP/1.1 412 Precondition Failed\r\n");
87 hprintf("Content-Length: 0\r\n\r\n");
90 FreeStrBuf(&dav_roomname);
96 * Ok, attempt to delete the item.
98 serv_printf("DELE %ld", dav_msgnum);
99 serv_getln(buf, sizeof buf);
101 hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
102 dav_common_headers();
103 hprintf("Content-Length: 0\r\n\r\n");
108 hprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
109 dav_common_headers();
110 hprintf("Content-Length: 0\r\n\r\n");
114 FreeStrBuf(&dav_roomname);