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);
37 int found_content_type = 0;
40 /* First, break off the "/groupdav/" prefix */
41 remove_token(dav_pathname, 0, '/');
42 remove_token(dav_pathname, 0, '/');
44 /* Now extract the message euid */
45 n = num_tokens(dav_pathname, '/');
46 extract_token(dav_uid, dav_pathname, n-1, '/');
47 remove_token(dav_pathname, n-1, '/');
49 /* What's left is the room name. Remove trailing slashes. */
50 if (dav_pathname[strlen(dav_pathname)-1] == '/') {
51 dav_pathname[strlen(dav_pathname)-1] = 0;
53 strcpy(dav_roomname, dav_pathname);
55 /* Go to the correct room. */
56 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
57 gotoroom(dav_roomname);
59 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
60 wprintf("HTTP/1.1 404 not found\n");
61 groupdav_common_headers();
63 "Content-Type: text/plain\n"
65 "There is no folder called \"%s\" on this server.\n",
71 dav_msgnum = locate_message_by_uid(dav_uid);
72 serv_printf("MSG2 %ld", dav_msgnum);
75 wprintf("HTTP/1.1 404 not found\n");
76 groupdav_common_headers();
78 "Content-Type: text/plain\n"
80 "Object \"%s\" was not found in the \"%s\" folder.\n",
87 wprintf("HTTP/1.1 200 OK\n");
88 groupdav_common_headers();
89 wprintf("ETag: \"%ld\"\n", dav_msgnum);
90 while (serv_gets(buf), strcmp(buf, "000")) {
91 if (!strncasecmp(buf, "Content-type: ", 14)) {
92 found_content_type = 1;
94 if ((strlen(buf) == 0) && (found_content_type == 0)) {
95 wprintf("Content-type: text/plain\n");