4 * Handles GroupDAV GET requests.
14 * Fetch the entire contents of the room as one big ics file.
15 * This is for "webcal://" type access.
17 void groupdav_get_big_ics(void) {
20 serv_puts("ICAL getics");
21 serv_getln(buf, sizeof buf);
23 wprintf("HTTP/1.1 404 not found\r\n");
24 groupdav_common_headers();
26 "Content-Type: text/plain\r\n"
34 wprintf("HTTP/1.1 200 OK\r\n");
35 groupdav_common_headers();
36 wprintf("Content-type: text/calendar; charset=UTF-8\r\n");
38 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
39 wprintf("%s\r\n", buf);
46 * The pathname is always going to take one of two formats:
47 * /groupdav/room_name/euid (GroupDAV)
48 * /groupdav/room_name (webcal)
50 void groupdav_get(char *dav_pathname) {
51 char dav_roomname[1024];
53 long dav_msgnum = (-1);
56 int found_content_type = 0;
58 if (num_tokens(dav_pathname, '/') < 3) {
59 wprintf("HTTP/1.1 404 not found\r\n");
60 groupdav_common_headers();
62 "Content-Type: text/plain\r\n"
64 "The object you requested was not found.\r\n"
69 extract_token(dav_roomname, dav_pathname, 2, '/', sizeof dav_roomname);
70 extract_token(dav_uid, dav_pathname, 3, '/', sizeof dav_uid);
71 if ((!strcasecmp(dav_uid, "ics")) || (!strcasecmp(dav_uid, "calendar.ics"))) {
75 /* Go to the correct room. */
76 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
77 gotoroom(dav_roomname);
79 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
80 wprintf("HTTP/1.1 404 not found\r\n");
81 groupdav_common_headers();
83 "Content-Type: text/plain\r\n"
85 "There is no folder called \"%s\" on this server.\r\n",
91 /** GET on the collection itself returns an ICS of the entire collection.
93 if (!strcasecmp(dav_uid, "")) {
94 groupdav_get_big_ics();
98 dav_msgnum = locate_message_by_uid(dav_uid);
99 serv_printf("MSG2 %ld", dav_msgnum);
100 serv_getln(buf, sizeof buf);
102 wprintf("HTTP/1.1 404 not found\r\n");
103 groupdav_common_headers();
105 "Content-Type: text/plain\r\n"
107 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
114 wprintf("HTTP/1.1 200 OK\r\n");
115 groupdav_common_headers();
116 wprintf("etag: \"%ld\"\r\n", dav_msgnum);
117 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
119 wprintf("%s\r\n", buf);
121 else if (!strncasecmp(buf, "Date: ", 6)) {
122 wprintf("%s\r\n", buf);
124 else if (!strncasecmp(buf, "Content-type: ", 14)) {
126 if (bmstrcasestr(buf, "charset=")) {
127 wprintf("%s\r\n", buf);
130 wprintf("%s;charset=UTF-8\r\n", buf);
132 found_content_type = 1;
134 else if ((strlen(buf) == 0) && (in_body == 0)) {
135 if (!found_content_type) {
136 wprintf("Content-type: text/plain\r\n");