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);
72 /* Go to the correct room. */
73 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
74 gotoroom(dav_roomname);
76 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
77 wprintf("HTTP/1.1 404 not found\r\n");
78 groupdav_common_headers();
80 "Content-Type: text/plain\r\n"
82 "There is no folder called \"%s\" on this server.\r\n",
88 /** GET on the collection itself returns an ICS of the entire collection.
90 if (!strcasecmp(dav_uid, "")) {
91 groupdav_get_big_ics();
95 dav_msgnum = locate_message_by_uid(dav_uid);
96 serv_printf("MSG2 %ld", dav_msgnum);
97 serv_getln(buf, sizeof buf);
99 wprintf("HTTP/1.1 404 not found\r\n");
100 groupdav_common_headers();
102 "Content-Type: text/plain\r\n"
104 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
111 wprintf("HTTP/1.1 200 OK\r\n");
112 groupdav_common_headers();
113 wprintf("etag: \"%ld\"\r\n", dav_msgnum);
114 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
116 wprintf("%s\r\n", buf);
118 else if (!strncasecmp(buf, "Date: ", 6)) {
119 wprintf("%s\r\n", buf);
121 else if (!strncasecmp(buf, "Content-type: ", 14)) {
122 wprintf("%s\r\n", buf);
123 found_content_type = 1;
125 else if ((strlen(buf) == 0) && (in_body == 0)) {
126 if (!found_content_type) {
127 wprintf("Content-type: text/plain\r\n");