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/msg_num
32 void groupdav_get(char *dav_pathname) {
33 char dav_roomname[SIZ];
36 int found_content_type = 0;
39 /* First, break off the "/groupdav/" prefix */
40 remove_token(dav_pathname, 0, '/');
41 remove_token(dav_pathname, 0, '/');
43 /* Now extract the message number */
44 n = num_tokens(dav_pathname, '/');
45 extract_token(dav_msgnum, dav_pathname, n-1, '/');
46 remove_token(dav_pathname, n-1, '/');
48 /* What's left is the room name. Remove trailing slashes. */
49 if (dav_pathname[strlen(dav_pathname)-1] == '/') {
50 dav_pathname[strlen(dav_pathname)-1] = 0;
52 strcpy(dav_roomname, dav_pathname);
54 /* Go to the correct room. */
55 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
56 gotoroom(dav_roomname);
58 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
59 wprintf("HTTP/1.1 404 not found\n");
60 groupdav_common_headers();
62 "Content-Type: text/plain\n"
64 "There is no folder called \"%s\" on this server.\n",
70 serv_printf("MSG2 %s", dav_msgnum);
73 wprintf("HTTP/1.1 404 not found\n");
74 groupdav_common_headers();
76 "Content-Type: text/plain\n"
78 "Object \"%s\" was not found in the \"%s\" folder.\n",
85 wprintf("HTTP/1.1 200 OK\n");
86 groupdav_common_headers();
87 wprintf("ETag: \"%s\"\n", dav_msgnum);
88 while (serv_gets(buf), strcmp(buf, "000")) {
89 if (!strncasecmp(buf, "Content-type: ", 14)) {
90 found_content_type = 1;
92 if ((strlen(buf) == 0) && (found_content_type == 0)) {
93 wprintf("Content-type: text/plain\n");