5 * \defgraup GroupdavGet Handle GroupDAV GET requests.
6 * \ingroup WebcitHttpServerGDav
11 #include "webserver.h"
16 * \brief The pathname is always going to be /groupdav/room_name/euid
17 * \param dav_pathname the pathname to print
19 void groupdav_get(char *dav_pathname) {
20 char dav_roomname[SIZ];
22 long dav_msgnum = (-1);
26 int found_content_type = 0;
28 /** First, break off the "/groupdav/" prefix */
29 remove_token(dav_pathname, 0, '/');
30 remove_token(dav_pathname, 0, '/');
32 /** Now extract the message euid */
33 n = num_tokens(dav_pathname, '/');
34 extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
35 remove_token(dav_pathname, n-1, '/');
37 /** What's left is the room name. Remove trailing slashes. */
38 if (dav_pathname[strlen(dav_pathname)-1] == '/') {
39 dav_pathname[strlen(dav_pathname)-1] = 0;
41 strcpy(dav_roomname, dav_pathname);
43 /** Go to the correct room. */
44 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
45 gotoroom(dav_roomname);
47 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
48 wprintf("HTTP/1.1 404 not found\r\n");
49 groupdav_common_headers();
51 "Content-Type: text/plain\r\n"
53 "There is no folder called \"%s\" on this server.\r\n",
59 dav_msgnum = locate_message_by_uid(dav_uid);
60 serv_printf("MSG2 %ld", dav_msgnum);
61 serv_getln(buf, sizeof buf);
63 wprintf("HTTP/1.1 404 not found\r\n");
64 groupdav_common_headers();
66 "Content-Type: text/plain\r\n"
68 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
75 wprintf("HTTP/1.1 200 OK\r\n");
76 groupdav_common_headers();
77 wprintf("etag: \"%ld\"\r\n", dav_msgnum);
78 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
79 if (!strncasecmp(buf, "Date: ", 6)) {
80 wprintf("%s\r\n", buf);
82 if (!strncasecmp(buf, "Content-type: ", 14)) {
83 wprintf("%s\r\n", buf);
84 found_content_type = 1;
86 if ((strlen(buf) == 0) && (in_body == 0)) {
87 if (!found_content_type) {
88 wprintf("Content-type: text/plain\r\n");
93 wprintf("%s\r\n", buf);