2 * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
4 * Copyright (c) 2005-2010 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "webserver.h"
26 * The pathname is always going to be /groupdav/room_name/msg_num
28 void groupdav_options(void)
33 long dav_msgnum = (-1);
38 http_datestring(datestring, sizeof datestring, now);
40 dav_roomname = NewStrBuf();
41 dav_uid = NewStrBuf();
42 StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
43 StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
46 * If the room name is blank, the client is doing a top-level OPTIONS.
48 if (StrLength(dav_roomname) == 0) {
49 hprintf("HTTP/1.1 200 OK\r\n");
50 groupdav_common_headers();
51 hprintf("Date: %s\r\n", datestring);
52 hprintf("DAV: 1\r\n");
53 hprintf("Allow: OPTIONS, PROPFIND\r\n");
57 FreeStrBuf(&dav_roomname);
62 /* Go to the correct room. */
63 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
64 gotoroom(dav_roomname);
67 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
68 hprintf("HTTP/1.1 404 not found\r\n");
69 groupdav_common_headers();
70 hprintf("Date: %s\r\n", datestring);
72 "Content-Type: text/plain\r\n");
75 "There is no folder called \"%s\" on this server.\r\n",
79 FreeStrBuf(&dav_roomname);
84 /* If dav_uid is non-empty, client is requesting an OPTIONS on
85 * a specific item in the room.
87 if (StrLength(dav_uid) != 0) {
89 dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
91 hprintf("HTTP/1.1 404 not found\r\n");
92 groupdav_common_headers();
93 hprintf("Content-Type: text/plain\r\n");
96 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
100 FreeStrBuf(&dav_roomname);
101 FreeStrBuf(&dav_uid);
105 hprintf("HTTP/1.1 200 OK\r\n");
106 groupdav_common_headers();
107 hprintf("Date: %s\r\n", datestring);
108 hprintf("DAV: 1\r\n");
109 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
113 FreeStrBuf(&dav_roomname);
114 FreeStrBuf(&dav_uid);
118 FreeStrBuf(&dav_roomname);
119 FreeStrBuf(&dav_uid);
122 * We got to this point, which means that the client is requesting
123 * an OPTIONS on the room itself.
125 hprintf("HTTP/1.1 200 OK\r\n");
126 groupdav_common_headers();
127 hprintf("Date: %s\r\n", datestring);
128 hprintf("DAV: 1\r\n");
129 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");