5 * \defgraup GroupdavGet Handle GroupDAV GET requests.
10 #include "webserver.h"
15 * \briefThe pathname is always going to be /groupdav/room_name/euid
16 * \param dav_pathname the pathname to print
18 void groupdav_get(char *dav_pathname) {
19 char dav_roomname[SIZ];
21 long dav_msgnum = (-1);
25 int found_content_type = 0;
27 /** First, break off the "/groupdav/" prefix */
28 remove_token(dav_pathname, 0, '/');
29 remove_token(dav_pathname, 0, '/');
31 /** Now extract the message euid */
32 n = num_tokens(dav_pathname, '/');
33 extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
34 remove_token(dav_pathname, n-1, '/');
36 /** What's left is the room name. Remove trailing slashes. */
37 if (dav_pathname[strlen(dav_pathname)-1] == '/') {
38 dav_pathname[strlen(dav_pathname)-1] = 0;
40 strcpy(dav_roomname, dav_pathname);
42 /** Go to the correct room. */
43 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
44 gotoroom(dav_roomname);
46 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
47 wprintf("HTTP/1.1 404 not found\r\n");
48 groupdav_common_headers();
50 "Content-Type: text/plain\r\n"
52 "There is no folder called \"%s\" on this server.\r\n",
58 dav_msgnum = locate_message_by_uid(dav_uid);
59 serv_printf("MSG2 %ld", dav_msgnum);
60 serv_getln(buf, sizeof buf);
62 wprintf("HTTP/1.1 404 not found\r\n");
63 groupdav_common_headers();
65 "Content-Type: text/plain\r\n"
67 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
74 wprintf("HTTP/1.1 200 OK\r\n");
75 groupdav_common_headers();
76 wprintf("etag: \"%ld\"\r\n", dav_msgnum);
77 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
78 if (!strncasecmp(buf, "Date: ", 6)) {
79 wprintf("%s\r\n", buf);
81 if (!strncasecmp(buf, "Content-type: ", 14)) {
82 wprintf("%s\r\n", buf);
83 found_content_type = 1;
85 if ((strlen(buf) == 0) && (in_body == 0)) {
86 if (!found_content_type) {
87 wprintf("Content-type: text/plain\r\n");
92 wprintf("%s\r\n", buf);