4 * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
13 * The pathname is always going to be /groupdav/room_name/msg_num
15 void groupdav_options(void)
20 long dav_msgnum = (-1);
25 http_datestring(datestring, sizeof datestring, now);
27 dav_roomname = NewStrBuf();
28 dav_uid = NewStrBuf();
29 StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
30 StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
33 * If the room name is blank, the client is doing a top-level OPTIONS.
35 if (StrLength(dav_roomname) == 0) {
36 hprintf("HTTP/1.1 200 OK\r\n");
37 groupdav_common_headers();
38 hprintf("Date: %s\r\n", datestring);
39 hprintf("DAV: 1\r\n");
40 hprintf("Allow: OPTIONS, PROPFIND\r\n");
44 FreeStrBuf(&dav_roomname);
49 /* Go to the correct room. */
50 if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
51 gotoroom(dav_roomname);
54 if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
55 hprintf("HTTP/1.1 404 not found\r\n");
56 groupdav_common_headers();
57 hprintf("Date: %s\r\n", datestring);
59 "Content-Type: text/plain\r\n");
62 "There is no folder called \"%s\" on this server.\r\n",
66 FreeStrBuf(&dav_roomname);
71 /* If dav_uid is non-empty, client is requesting an OPTIONS on
72 * a specific item in the room.
74 if (StrLength(dav_uid) != 0) {
76 dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
78 hprintf("HTTP/1.1 404 not found\r\n");
79 groupdav_common_headers();
80 hprintf("Content-Type: text/plain\r\n");
83 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
87 FreeStrBuf(&dav_roomname);
92 hprintf("HTTP/1.1 200 OK\r\n");
93 groupdav_common_headers();
94 hprintf("Date: %s\r\n", datestring);
95 hprintf("DAV: 1\r\n");
96 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
100 FreeStrBuf(&dav_roomname);
101 FreeStrBuf(&dav_uid);
105 FreeStrBuf(&dav_roomname);
106 FreeStrBuf(&dav_uid);
109 * We got to this point, which means that the client is requesting
110 * an OPTIONS on the room itself.
112 hprintf("HTTP/1.1 200 OK\r\n");
113 groupdav_common_headers();
114 hprintf("Date: %s\r\n", datestring);
115 hprintf("DAV: 1\r\n");
116 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");