4 * Handles GroupDAV DELETE requests.
6 * Copyright (c) 2005-2010 by the citadel.org team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "webserver.h"
29 * The pathname is always going to be /groupdav/room_name/euid
31 void groupdav_delete(void)
35 long dav_msgnum = (-1);
38 StrBuf *dav_roomname = NewStrBuf();
40 /* Now extract the message euid */
41 n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
42 extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
43 StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
45 ///* What's left is the room name. Remove trailing slashes. */
46 //len = StrLength(WCC->Hdr->HR.ReqLine);
47 //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
48 // StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
50 //StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
52 /* Go to the correct room. */
53 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
54 gotoroom(dav_roomname);
56 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
57 hprintf("HTTP/1.1 404 not found\r\n");
58 groupdav_common_headers();
59 hprintf("Content-Length: 0\r\n\r\n");
62 FreeStrBuf(&dav_roomname);
66 dav_msgnum = locate_message_by_uid(dav_uid);
69 * If no item exists with the requested uid ... simple error.
71 if (dav_msgnum < 0L) {
72 hprintf("HTTP/1.1 404 Not Found\r\n");
73 groupdav_common_headers();
74 hprintf("Content-Length: 0\r\n\r\n");
77 FreeStrBuf(&dav_roomname);
82 * It's there ... check the ETag and make sure it matches
85 if (StrLength(WCC->Hdr->HR.dav_ifmatch) > 0) {
86 if (StrTol(WCC->Hdr->HR.dav_ifmatch) != dav_msgnum) {
87 hprintf("HTTP/1.1 412 Precondition Failed\r\n");
88 groupdav_common_headers();
89 hprintf("Content-Length: 0\r\n\r\n");
92 FreeStrBuf(&dav_roomname);
98 * Ok, attempt to delete the item.
100 serv_printf("DELE %ld", dav_msgnum);
101 serv_getln(buf, sizeof buf);
103 hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
104 groupdav_common_headers();
105 hprintf("Content-Length: 0\r\n\r\n");
110 hprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
111 groupdav_common_headers();
112 hprintf("Content-Length: 0\r\n\r\n");
116 FreeStrBuf(&dav_roomname);