5 * \defgroup GroupdavDel Handle GroupDAV DELETE requests.
10 #include "webserver.h"
15 * \brief The pathname is always going to be /groupdav/room_name/euid
16 * \param dav_pathname the groupdav pathname
17 * \param dav_ifmatch item to delete ????
19 void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
20 char dav_roomname[SIZ];
22 long dav_msgnum = (-1);
26 /** First, break off the "/groupdav/" prefix */
27 remove_token(dav_pathname, 0, '/');
28 remove_token(dav_pathname, 0, '/');
30 /** Now extract the message euid */
31 n = num_tokens(dav_pathname, '/');
32 extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
33 remove_token(dav_pathname, n-1, '/');
35 /** What's left is the room name. Remove trailing slashes. */
36 if (dav_pathname[strlen(dav_pathname)-1] == '/') {
37 dav_pathname[strlen(dav_pathname)-1] = 0;
39 strcpy(dav_roomname, dav_pathname);
41 /** Go to the correct room. */
42 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
43 gotoroom(dav_roomname);
45 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
46 wprintf("HTTP/1.1 404 not found\r\n");
47 groupdav_common_headers();
48 wprintf("Content-Length: 0\r\n\r\n");
52 dav_msgnum = locate_message_by_uid(dav_uid);
55 * If no item exists with the requested uid ... simple error.
57 if (dav_msgnum < 0L) {
58 wprintf("HTTP/1.1 404 Not Found\r\n");
59 groupdav_common_headers();
60 wprintf("Content-Length: 0\r\n\r\n");
65 * It's there ... check the ETag and make sure it matches
68 if (strlen(dav_ifmatch) > 0) {
69 if (atol(dav_ifmatch) != dav_msgnum) {
70 wprintf("HTTP/1.1 412 Precondition Failed\r\n");
71 groupdav_common_headers();
72 wprintf("Content-Length: 0\r\n\r\n");
78 * Ok, attempt to delete the item.
80 serv_printf("DELE %ld", dav_msgnum);
81 serv_getln(buf, sizeof buf);
83 wprintf("HTTP/1.1 204 No Content\r\n"); /* success */
84 groupdav_common_headers();
85 wprintf("Content-Length: 0\r\n\r\n");
88 wprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
89 groupdav_common_headers();
90 wprintf("Content-Length: 0\r\n\r\n");