4 * Handles GroupDAV GET requests.
14 #include <sys/types.h>
16 #include <sys/socket.h>
25 #include "webserver.h"
30 * The pathname is always going to be /groupdav/room_name/euid
32 void groupdav_get(char *dav_pathname) {
33 char dav_roomname[SIZ];
35 long dav_msgnum = (-1);
39 int found_content_type = 0;
41 /* First, break off the "/groupdav/" prefix */
42 remove_token(dav_pathname, 0, '/');
43 remove_token(dav_pathname, 0, '/');
45 /* Now extract the message euid */
46 n = num_tokens(dav_pathname, '/');
47 extract_token(dav_uid, dav_pathname, n-1, '/');
48 remove_token(dav_pathname, n-1, '/');
50 /* What's left is the room name. Remove trailing slashes. */
51 if (dav_pathname[strlen(dav_pathname)-1] == '/') {
52 dav_pathname[strlen(dav_pathname)-1] = 0;
54 strcpy(dav_roomname, dav_pathname);
56 /* Go to the correct room. */
57 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
58 gotoroom(dav_roomname);
60 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
61 wprintf("HTTP/1.1 404 not found\r\n");
62 groupdav_common_headers();
64 "Content-Type: text/plain\r\n"
66 "There is no folder called \"%s\" on this server.\r\n",
72 dav_msgnum = locate_message_by_uid(dav_uid);
73 serv_printf("MSG2 %ld", dav_msgnum);
76 wprintf("HTTP/1.1 404 not found\r\n");
77 groupdav_common_headers();
79 "Content-Type: text/plain\r\n"
81 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
88 wprintf("HTTP/1.1 200 OK\r\n");
89 groupdav_common_headers();
90 wprintf("ETag: \"%ld\"\r\n", dav_msgnum);
91 while (serv_gets(buf), strcmp(buf, "000")) {
92 if (!strncasecmp(buf, "Date: ", 6)) {
93 wprintf("%s\r\n", buf);
95 if (!strncasecmp(buf, "Content-type: ", 14)) {
96 wprintf("%s\r\n", buf);
97 found_content_type = 1;
99 if ((strlen(buf) == 0) && (in_body == 0)) {
100 if (!found_content_type) {
101 wprintf("Content-type: text/plain\r\n");
106 wprintf("%s\r\n", buf);