4 * Handles GroupDAV DELETE requests.
14 * The pathname is always going to be /groupdav/room_name/euid
16 void groupdav_delete(StrBuf
*dav_pathname
, char *dav_ifmatch
) {
18 long dav_msgnum
= (-1);
22 /* First, break off the "/groupdav/" prefix */
23 StrBufCutLeft(dav_pathname
, 9);
25 /* Now extract the message euid */
26 n
= StrBufNum_tokens(dav_pathname
, '/');
27 extract_token(dav_uid
, ChrPtr(dav_pathname
), n
-1, '/', sizeof dav_uid
);
28 StrBufRemove_token(dav_pathname
, n
-1, '/');
30 /* What's left is the room name. Remove trailing slashes. */
31 //len = StrLength(dav_pathname);
32 //if ((len > 0) && (ChrPtr(dav_pathname)[len-1] == '/')) {
33 // StrBufCutRight(dav_pathname, 1);
35 StrBufCutLeft(dav_pathname
, 1);
37 /* Go to the correct room. */
38 if (strcasecmp(ChrPtr(WC
->wc_roomname
), ChrPtr(dav_pathname
))) {
39 gotoroom(dav_pathname
);
41 if (strcasecmp(ChrPtr(WC
->wc_roomname
), ChrPtr(dav_pathname
))) {
42 hprintf("HTTP/1.1 404 not found\r\n");
43 groupdav_common_headers();
44 hprintf("Content-Length: 0\r\n\r\n");
48 dav_msgnum
= locate_message_by_uid(dav_uid
);
51 * If no item exists with the requested uid ... simple error.
53 if (dav_msgnum
< 0L) {
54 hprintf("HTTP/1.1 404 Not Found\r\n");
55 groupdav_common_headers();
56 hprintf("Content-Length: 0\r\n\r\n");
61 * It's there ... check the ETag and make sure it matches
64 if (!IsEmptyStr(dav_ifmatch
)) {
65 if (atol(dav_ifmatch
) != dav_msgnum
) {
66 hprintf("HTTP/1.1 412 Precondition Failed\r\n");
67 groupdav_common_headers();
68 hprintf("Content-Length: 0\r\n\r\n");
74 * Ok, attempt to delete the item.
76 serv_printf("DELE %ld", dav_msgnum
);
77 serv_getln(buf
, sizeof buf
);
79 hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
80 groupdav_common_headers();
81 hprintf("Content-Length: 0\r\n\r\n");
84 hprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
85 groupdav_common_headers();
86 hprintf("Content-Length: 0\r\n\r\n");