4 * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
5 * \ingroup WebcitHttpServerGDav
10 #include "webserver.h"
14 * The pathname is always going to be /groupdav/room_name/msg_num
16 void groupdav_options(char *dav_pathname) {
17 char dav_roomname[256];
19 long dav_msgnum = (-1);
24 http_datestring(datestring, sizeof datestring, now);
26 extract_token(dav_roomname, dav_pathname, 2, '/', sizeof dav_roomname);
27 extract_token(dav_uid, dav_pathname, 3, '/', sizeof dav_uid);
30 * If the room name is blank, the client is doing a top-level OPTIONS.
32 if (strlen(dav_roomname) == 0) {
33 wprintf("HTTP/1.1 200 OK\r\n");
34 groupdav_common_headers();
35 wprintf("Date: %s\r\n", datestring);
36 wprintf("Allow: OPTIONS, PROPFIND\r\n");
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("Date: %s\r\n", datestring);
50 "Content-Type: text/plain\r\n"
52 "There is no folder called \"%s\" on this server.\r\n",
58 /* If dav_uid is non-empty, client is requesting an OPTIONS on
59 * a specific item in the room.
61 if (strlen(dav_uid) > 0) {
63 dav_msgnum = locate_message_by_uid(dav_uid);
65 wprintf("HTTP/1.1 404 not found\r\n");
66 groupdav_common_headers();
68 "Content-Type: text/plain\r\n"
70 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
77 wprintf("HTTP/1.1 200 OK\r\n");
78 groupdav_common_headers();
79 wprintf("Date: %s\r\n", datestring);
80 wprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
87 * We got to this point, which means that the client is requesting
88 * an OPTIONS on the room itself.
90 wprintf("HTTP/1.1 200 OK\r\n");
91 groupdav_common_headers();
92 wprintf("Date: %s\r\n", datestring);
93 wprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");