4 * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
14 #include <sys/types.h>
16 #include <sys/socket.h>
25 #include "webserver.h"
29 * The pathname is always going to be /groupdav/room_name/msg_num
31 void groupdav_options(char *dav_pathname) {
32 char dav_roomname[256];
34 long dav_msgnum = (-1);
39 http_datestring(datestring, sizeof datestring, now);
41 extract_token(dav_roomname, dav_pathname, 2, '/', sizeof dav_roomname);
42 extract_token(dav_uid, dav_pathname, 3, '/', sizeof dav_uid);
45 * If the room name is blank, the client is doing a top-level OPTIONS.
47 if (strlen(dav_roomname) == 0) {
48 wprintf("HTTP/1.1 200 OK\r\n");
49 groupdav_common_headers();
50 wprintf("Date: %s\r\n", datestring);
51 wprintf("Allow: OPTIONS, PROPFIND\r\n");
56 /* Go to the correct room. */
57 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
58 gotoroom(dav_roomname);
60 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
61 wprintf("HTTP/1.1 404 not found\r\n");
62 groupdav_common_headers();
63 wprintf("Date: %s\r\n", datestring);
65 "Content-Type: text/plain\r\n"
67 "There is no folder called \"%s\" on this server.\r\n",
73 /* If dav_uid is non-empty, client is requesting an OPTIONS on
74 * a specific item in the room.
76 if (strlen(dav_uid) > 0) {
78 dav_msgnum = locate_message_by_uid(dav_uid);
80 wprintf("HTTP/1.1 404 not found\r\n");
81 groupdav_common_headers();
83 "Content-Type: text/plain\r\n"
85 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
92 wprintf("HTTP/1.1 200 OK\r\n");
93 groupdav_common_headers();
94 wprintf("Date: %s\r\n", datestring);
95 wprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
102 * We got to this point, which means that the client is requesting
103 * an OPTIONS on the room itself.
105 wprintf("HTTP/1.1 200 OK\r\n");
106 groupdav_common_headers();
107 wprintf("Date: %s\r\n", datestring);
108 wprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");