char buf[SIZ];
char roomname[SIZ];
int view;
+ char datestring[SIZ];
+ time_t now;
+
+ now = time(NULL);
+ http_datestring(datestring, sizeof datestring, now);
/*
* Be rude. Completely ignore the XML request and simply send them
*/
wprintf("HTTP/1.0 207 Multi-Status\r\n");
groupdav_common_headers();
+ wprintf("Date: %s\r\n", datestring);
wprintf("Content-type: text/xml\r\n");
+ wprintf("Content-encoding: identity\r\n");
begin_burst();
- wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"
- "<D:multistatus xmlns:D=\"DAV:\">\r\n"
+ wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ "<D:multistatus xmlns:D=\"DAV:\">\n"
);
serv_puts("LKRA");
*/
if ((view == VIEW_CALENDAR) || (view == VIEW_TASKS) || (view == VIEW_ADDRESSBOOK) ) {
- wprintf(" <D:response>\r\n");
+ wprintf(" <D:response>\n");
wprintf(" <D:href>");
if (strlen(WC->http_host) > 0) {
}
wprintf("/groupdav/");
urlescputs(roomname);
- wprintf("/</D:href>\r\n");
+ wprintf("/</D:href>\n");
- wprintf(" <D:propstat>\r\n");
- wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\r\n");
- wprintf(" <D:prop>\r\n");
+ wprintf(" <D:propstat>\n");
+ wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\n");
+ wprintf(" <D:prop>\n");
wprintf(" <D:displayname>");
escputs( roomname);
- wprintf( "</D:displayname>\r\n");
+ wprintf( "</D:displayname>\n");
wprintf(" <D:resourcetype><D:collection/>");
switch(view) {
case VIEW_CALENDAR:
- wprintf(" <G:vevent-collection />\r\n");
+ wprintf(" <G:vevent-collection />\n");
break;
case VIEW_TASKS:
- wprintf(" <G:vtodo-collection />\r\n");
+ wprintf(" <G:vtodo-collection />\n");
break;
case VIEW_ADDRESSBOOK:
- wprintf(" <G:vcard-collection />\r\n");
+ wprintf(" <G:vcard-collection />\n");
break;
}
- wprintf( "</D:resourcetype>\r\n");
- wprintf(" </D:prop>\r\n");
- wprintf(" </D:propstat>\r\n");
- wprintf(" </D:response>\r\n");
+ wprintf( "</D:resourcetype>\n");
+ wprintf(" </D:prop>\n");
+ wprintf(" </D:propstat>\n");
+ wprintf(" </D:response>\n");
}
}
- wprintf("</D:multistatus>\r\n\r\n\r\n");
+ wprintf("</D:multistatus>\n\n\n");
end_burst();
}
long *msgs = NULL;
int num_msgs = 0;
int i;
+ char datestring[SIZ];
+ time_t now;
+
+ now = time(NULL);
+ http_datestring(datestring, sizeof datestring, now);
+
/* First, break off the "/groupdav/" prefix */
remove_token(dav_pathname, 0, '/');
if (strcasecmp(WC->wc_roomname, dav_roomname)) {
wprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
+ wprintf("Date: %s\r\n", datestring);
wprintf(
"Content-Type: text/plain\r\n"
"\r\n"
*/
wprintf("HTTP/1.0 207 Multi-Status\r\n");
groupdav_common_headers();
+ wprintf("Date: %s\r\n", datestring);
wprintf("Content-type: text/xml\r\n");
+ wprintf("Content-encoding: identity\r\n");
begin_burst();
- wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"
- "<D:multistatus xmlns:D=\"DAV:\">\r\n"
+ wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ "<D:multistatus xmlns:D=\"DAV:\">\n"
);
serv_puts("MSGS ALL");
}
if (strlen(uid) > 0) {
- wprintf(" <D:response>\r\n");
+ wprintf(" <D:response>\n");
wprintf(" <D:href>");
if (strlen(WC->http_host) > 0) {
wprintf("%s://%s",
urlescputs(WC->wc_roomname);
euid_escapize(encoded_uid, uid);
wprintf("/%s", encoded_uid);
- wprintf("</D:href>\r\n");
- wprintf(" <D:propstat>\r\n");
- wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\r\n");
- wprintf(" <D:prop><D:getetag>\"%ld\"</D:getetag></D:prop>\r\n", msgs[i]);
- wprintf(" </D:propstat>\r\n");
- wprintf(" </D:response>\r\n");
+ wprintf("</D:href>\n");
+ wprintf(" <D:propstat>\n");
+ wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\n");
+ wprintf(" <D:prop><D:getetag>\"%ld\"</D:getetag></D:prop>\n", msgs[i]);
+ wprintf(" </D:propstat>\n");
+ wprintf(" </D:response>\n");
}
}
- wprintf("</D:multistatus>\r\n\r\n\r\n");
+ wprintf("</D:multistatus>\n\n\n");
end_burst();
if (msgs != NULL) {
--- /dev/null
+/*
+ * $Id$
+ *
+ * Function to generate HTTP-compliant textual time/date stamp
+ * (This module was lifted directly from the Citadel server source)
+ *
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+# include <time.h>
+
+static char *httpdate_months[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+static char *httpdate_weekdays[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+
+
+/*
+ * Supplied with a unix timestamp, generate a textual time/date stamp
+ */
+void http_datestring(char *buf, size_t n, time_t xtime) {
+ struct tm t;
+
+ long offset;
+ char offsign;
+
+ localtime_r(&xtime, &t);
+
+ /* Convert "seconds west of GMT" to "hours/minutes offset" */
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+ offset = t.tm_gmtoff;
+#else
+ offset = timezone;
+#endif
+ if (offset > 0) {
+ offsign = '+';
+ }
+ else {
+ offset = 0L - offset;
+ offsign = '-';
+ }
+ offset = ( (offset / 3600) * 100 ) + ( offset % 60 );
+
+ snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
+ httpdate_weekdays[t.tm_wday],
+ t.tm_mday,
+ httpdate_months[t.tm_mon],
+ t.tm_year + 1900,
+ t.tm_hour,
+ t.tm_min,
+ t.tm_sec,
+ offsign, offset
+ );
+}
+