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);
23 StrBuf *dav_roomname = NewStrBuf();
25 /* Now extract the message euid */
26 n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
27 extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
28 StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
30 ///* What's left is the room name. Remove trailing slashes. */
31 //len = StrLength(WCC->Hdr->HR.ReqLine);
32 //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
33 // StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
35 //StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
37 /* Go to the correct room. */
38 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
39 gotoroom(dav_roomname);
41 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
42 hprintf("HTTP/1.1 404 not found\r\n");
43 groupdav_common_headers();
44 hprintf("Content-Length: 0\r\n\r\n");
47 FreeStrBuf(&dav_roomname);
51 dav_msgnum = locate_message_by_uid(dav_uid);
54 * If no item exists with the requested uid ... simple error.
56 if (dav_msgnum < 0L) {
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);
67 * It's there ... check the ETag and make sure it matches
70 if (StrLength(WCC->Hdr->HR.dav_ifmatch) > 0) {
71 if (StrTol(WCC->Hdr->HR.dav_ifmatch) != dav_msgnum) {
72 hprintf("HTTP/1.1 412 Precondition Failed\r\n");
73 groupdav_common_headers();
74 hprintf("Content-Length: 0\r\n\r\n");
77 FreeStrBuf(&dav_roomname);
83 * Ok, attempt to delete the item.
85 serv_printf("DELE %ld", dav_msgnum);
86 serv_getln(buf, sizeof buf);
88 hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
89 groupdav_common_headers();
90 hprintf("Content-Length: 0\r\n\r\n");
95 hprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
96 groupdav_common_headers();
97 hprintf("Content-Length: 0\r\n\r\n");
101 FreeStrBuf(&dav_roomname);