4 * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
7 * Copyright (c) 2005-2010 by the citadel.org team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "webserver.h"
29 * The pathname is always going to be /groupdav/room_name/msg_num
31 void groupdav_options(void)
36 long dav_msgnum = (-1);
41 http_datestring(datestring, sizeof datestring, now);
43 dav_roomname = NewStrBuf();
44 dav_uid = NewStrBuf();
45 StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
46 StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
49 * If the room name is blank, the client is doing a top-level OPTIONS.
51 if (StrLength(dav_roomname) == 0) {
52 hprintf("HTTP/1.1 200 OK\r\n");
53 groupdav_common_headers();
54 hprintf("Date: %s\r\n", datestring);
55 hprintf("DAV: 1\r\n");
56 hprintf("Allow: OPTIONS, PROPFIND\r\n");
60 FreeStrBuf(&dav_roomname);
65 /* Go to the correct room. */
66 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
67 gotoroom(dav_roomname);
70 if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
71 hprintf("HTTP/1.1 404 not found\r\n");
72 groupdav_common_headers();
73 hprintf("Date: %s\r\n", datestring);
75 "Content-Type: text/plain\r\n");
78 "There is no folder called \"%s\" on this server.\r\n",
82 FreeStrBuf(&dav_roomname);
87 /* If dav_uid is non-empty, client is requesting an OPTIONS on
88 * a specific item in the room.
90 if (StrLength(dav_uid) != 0) {
92 dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
94 hprintf("HTTP/1.1 404 not found\r\n");
95 groupdav_common_headers();
96 hprintf("Content-Type: text/plain\r\n");
99 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
103 FreeStrBuf(&dav_roomname);
104 FreeStrBuf(&dav_uid);
108 hprintf("HTTP/1.1 200 OK\r\n");
109 groupdav_common_headers();
110 hprintf("Date: %s\r\n", datestring);
111 hprintf("DAV: 1\r\n");
112 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
116 FreeStrBuf(&dav_roomname);
117 FreeStrBuf(&dav_uid);
121 FreeStrBuf(&dav_roomname);
122 FreeStrBuf(&dav_uid);
125 * We got to this point, which means that the client is requesting
126 * an OPTIONS on the room itself.
128 hprintf("HTTP/1.1 200 OK\r\n");
129 groupdav_common_headers();
130 hprintf("Date: %s\r\n", datestring);
131 hprintf("DAV: 1\r\n");
132 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");