4 * Handles GroupDAV DELETE requests.
14 * The pathname is always going to be /groupdav/room_name/euid
16 void groupdav_delete(void)
20 long dav_msgnum = (-1);
24 /* Now extract the message euid */
25 n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
26 extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
27 StrBufRemove_token(WCC->Hdr->HR.ReqLine, n-1, '/');
29 /* What's left is the room name. Remove trailing slashes. */
30 //len = StrLength(WCC->Hdr->HR.ReqLine);
31 //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
32 // StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
34 StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
36 /* Go to the correct room. */
37 if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(WCC->Hdr->HR.ReqLine))) {
38 gotoroom(WCC->Hdr->HR.ReqLine);
40 if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(WCC->Hdr->HR.ReqLine))) {
41 hprintf("HTTP/1.1 404 not found\r\n");
42 groupdav_common_headers();
43 hprintf("Content-Length: 0\r\n\r\n");
47 dav_msgnum = locate_message_by_uid(dav_uid);
50 * If no item exists with the requested uid ... simple error.
52 if (dav_msgnum < 0L) {
53 hprintf("HTTP/1.1 404 Not Found\r\n");
54 groupdav_common_headers();
55 hprintf("Content-Length: 0\r\n\r\n");
60 * It's there ... check the ETag and make sure it matches
63 if (StrLength(WCC->Hdr->HR.dav_ifmatch) > 0) {
64 if (StrTol(WCC->Hdr->HR.dav_ifmatch) != dav_msgnum) {
65 hprintf("HTTP/1.1 412 Precondition Failed\r\n");
66 groupdav_common_headers();
67 hprintf("Content-Length: 0\r\n\r\n");
73 * Ok, attempt to delete the item.
75 serv_printf("DELE %ld", dav_msgnum);
76 serv_getln(buf, sizeof buf);
78 hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
79 groupdav_common_headers();
80 hprintf("Content-Length: 0\r\n\r\n");
83 hprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
84 groupdav_common_headers();
85 hprintf("Content-Length: 0\r\n\r\n");