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(StrBuf
*dav_pathname
) {
18 long dav_msgnum
= (-1);
23 http_datestring(datestring
, sizeof datestring
, now
);
25 dav_roomname
= NewStrBuf();
26 dav_uid
= NewStrBuf();
27 StrBufExtract_token(dav_roomname
, dav_pathname
, 2, '/');
28 StrBufExtract_token(dav_uid
, dav_pathname
, 3, '/');
31 * If the room name is blank, the client is doing a top-level OPTIONS.
33 if (StrLength(dav_roomname
) == 0) {
34 hprintf("HTTP/1.1 200 OK\r\n");
35 groupdav_common_headers();
36 hprintf("Date: %s\r\n", datestring
);
37 hprintf("DAV: 1\r\n");
38 hprintf("Allow: OPTIONS, PROPFIND\r\n");
42 FreeStrBuf(&dav_roomname
);
47 /* Go to the correct room. */
48 if (strcasecmp(ChrPtr(WC
->wc_roomname
), ChrPtr(dav_roomname
))) {
49 gotoroom(dav_roomname
);
52 if (strcasecmp(ChrPtr(WC
->wc_roomname
), ChrPtr(dav_roomname
))) {
53 hprintf("HTTP/1.1 404 not found\r\n");
54 groupdav_common_headers();
55 hprintf("Date: %s\r\n", datestring
);
57 "Content-Type: text/plain\r\n"
59 "There is no folder called \"%s\" on this server.\r\n",
64 FreeStrBuf(&dav_roomname
);
69 /* If dav_uid is non-empty, client is requesting an OPTIONS on
70 * a specific item in the room.
72 if (StrLength(dav_uid
) != 0) {
74 dav_msgnum
= locate_message_by_uid(ChrPtr(dav_uid
));
76 hprintf("HTTP/1.1 404 not found\r\n");
77 groupdav_common_headers();
79 "Content-Type: text/plain\r\n"
81 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
85 FreeStrBuf(&dav_roomname
);
87 begin_burst();end_burst();return;
90 hprintf("HTTP/1.1 200 OK\r\n");
91 groupdav_common_headers();
92 hprintf("Date: %s\r\n", datestring
);
93 hprintf("DAV: 1\r\n");
94 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
98 FreeStrBuf(&dav_roomname
);
103 FreeStrBuf(&dav_roomname
);
104 FreeStrBuf(&dav_uid
);
107 * We got to this point, which means that the client is requesting
108 * an OPTIONS on the room itself.
110 hprintf("HTTP/1.1 200 OK\r\n");
111 groupdav_common_headers();
112 hprintf("Date: %s\r\n", datestring
);
113 hprintf("DAV: 1\r\n");
114 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");