$Log$
+Revision 528.44 2005/02/05 22:58:46 ajc
+* All GroupDAV HTTP output is now \r\n instead of \n terminated.
+
Revision 528.43 2005/02/05 08:36:13 ajc
* Added an everything-buffering thingi so we can do Content-length:
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
-
char dav_uid[SIZ];
long dav_msgnum = (-1);
char buf[SIZ];
- int found_content_type = 0;
int n = 0;
/* First, break off the "/groupdav/" prefix */
gotoroom(dav_roomname);
}
if (strcasecmp(WC->wc_roomname, dav_roomname)) {
- wprintf("HTTP/1.1 404 not found\n");
+ wprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
return;
}
* If no item exists with the requested uid ... simple error.
*/
if (dav_msgnum < 0L) {
- wprintf("HTTP/1.1 404 Not Found\n");
+ wprintf("HTTP/1.1 404 Not Found\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
return;
}
*/
if (strlen(dav_ifmatch) > 0) {
if (atol(dav_ifmatch) != dav_msgnum) {
- wprintf("HTTP/1.1 412 Precondition Failed\n");
+ wprintf("HTTP/1.1 412 Precondition Failed\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
return;
}
}
serv_printf("DELE %ld", dav_msgnum);
serv_gets(buf);
if (buf[0] == '2') {
- wprintf("HTTP/1.1 204 No Content\n"); /* success */
+ wprintf("HTTP/1.1 204 No Content\r\n"); /* success */
groupdav_common_headers();
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
}
else {
- wprintf("HTTP/1.1 403 Forbidden\n"); /* access denied */
+ wprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
groupdav_common_headers();
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
}
return;
}
gotoroom(dav_roomname);
}
if (strcasecmp(WC->wc_roomname, dav_roomname)) {
- wprintf("HTTP/1.1 404 not found\n");
+ wprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
wprintf(
- "Content-Type: text/plain\n"
- "\n"
- "There is no folder called \"%s\" on this server.\n",
+ "Content-Type: text/plain\r\n"
+ "\r\n"
+ "There is no folder called \"%s\" on this server.\r\n",
dav_roomname
);
return;
serv_printf("MSG2 %ld", dav_msgnum);
serv_gets(buf);
if (buf[0] != '1') {
- wprintf("HTTP/1.1 404 not found\n");
+ wprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
wprintf(
- "Content-Type: text/plain\n"
- "\n"
- "Object \"%s\" was not found in the \"%s\" folder.\n",
+ "Content-Type: text/plain\r\n"
+ "\r\n"
+ "Object \"%s\" was not found in the \"%s\" folder.\r\n",
dav_uid,
dav_roomname
);
return;
}
- wprintf("HTTP/1.1 200 OK\n");
+ wprintf("HTTP/1.1 200 OK\r\n");
groupdav_common_headers();
- wprintf("ETag: \"%ld\"\n", dav_msgnum);
+ wprintf("ETag: \"%ld\"\r\n", dav_msgnum);
while (serv_gets(buf), strcmp(buf, "000")) {
if (!strncasecmp(buf, "Date: ", 6)) {
- wprintf("%s\n", buf);
+ wprintf("%s\r\n", buf);
}
if (!strncasecmp(buf, "Content-type: ", 14)) {
- wprintf("%s\n", buf);
+ wprintf("%s\r\n", buf);
found_content_type = 1;
}
if ((strlen(buf) == 0) && (in_body == 0)) {
if (!found_content_type) {
- wprintf("Content-type: text/plain\n");
+ wprintf("Content-type: text/plain\r\n");
}
in_body = 1;
}
if (in_body) {
- wprintf("%s\n", buf);
+ wprintf("%s\r\n", buf);
}
}
}
*/
void groupdav_common_headers(void) {
wprintf(
- "Server: %s / %s\n"
- "Connection: close\n",
+ "Server: %s / %s\r\n"
+ "Connection: close\r\n",
SERVER, serv_info.serv_software
);
}
}
if (!WC->logged_in) {
- wprintf("HTTP/1.1 401 Unauthorized\n");
+ wprintf("HTTP/1.1 401 Unauthorized\r\n");
groupdav_common_headers();
- wprintf("WWW-Authenticate: Basic realm=\"%s\"\n",
+ wprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n",
serv_info.serv_humannode);
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
return;
}
/*
* Couldn't find what we were looking for. Die in a car fire.
*/
- wprintf("HTTP/1.1 501 Method not implemented\n");
+ wprintf("HTTP/1.1 501 Method not implemented\r\n");
groupdav_common_headers();
- wprintf("Content-Type: text/plain\n"
- "\n"
- "GroupDAV method \"%s\" is not implemented.\n",
+ wprintf("Content-Type: text/plain\r\n"
+ "\r\n"
+ "GroupDAV method \"%s\" is not implemented.\r\n",
dav_method
);
}
* Be rude. Completely ignore the XML request and simply send them
* everything we know about. Let the client sort it out.
*/
- wprintf("HTTP/1.0 207 Multi-Status\n");
+ wprintf("HTTP/1.0 207 Multi-Status\r\n");
groupdav_common_headers();
- wprintf("Content-type: text/xml\n");
+ wprintf("Content-type: text/xml\r\n");
begin_burst();
- wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
- "<D:multistatus xmlns:D=\"DAV:\">\n"
+ wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"
+ "<D:multistatus xmlns:D=\"DAV:\">\r\n"
);
serv_puts("LKRA");
*/
if ((view == VIEW_CALENDAR) || (view == VIEW_TASKS) || (view == VIEW_ADDRESSBOOK) ) {
- wprintf(" <D:response>\n");
+ wprintf(" <D:response>\r\n");
wprintf(" <D:href>");
if (strlen(WC->http_host) > 0) {
}
wprintf("/groupdav/");
urlescputs(roomname);
- wprintf("/</D:href>\n");
+ wprintf("/</D:href>\r\n");
- wprintf(" <D:propstat>\n");
- wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\n");
- wprintf(" <D:prop>\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:displayname>");
escputs( roomname);
- wprintf( "</D:displayname>\n");
+ wprintf( "</D:displayname>\r\n");
wprintf(" <D:resourcetype><D:collection/>");
switch(view) {
case VIEW_CALENDAR:
- wprintf(" <G:vevent-collection />\n");
+ wprintf(" <G:vevent-collection />\r\n");
break;
case VIEW_TASKS:
- wprintf(" <G:vtodo-collection />\n");
+ wprintf(" <G:vtodo-collection />\r\n");
break;
case VIEW_ADDRESSBOOK:
- wprintf(" <G:vcard-collection />\n");
+ wprintf(" <G:vcard-collection />\r\n");
break;
}
- wprintf( "</D:resourcetype>\n");
- wprintf(" </D:prop>\n");
- wprintf(" </D:propstat>\n");
- wprintf(" </D:response>\n");
+ wprintf( "</D:resourcetype>\r\n");
+ wprintf(" </D:prop>\r\n");
+ wprintf(" </D:propstat>\r\n");
+ wprintf(" </D:response>\r\n");
}
}
- wprintf("</D:multistatus>\n\n\n");
+ wprintf("</D:multistatus>\r\n\r\n\r\n");
end_burst();
}
gotoroom(dav_roomname);
}
if (strcasecmp(WC->wc_roomname, dav_roomname)) {
- wprintf("HTTP/1.1 404 not found\n");
+ wprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
wprintf(
- "Content-Type: text/plain\n"
- "\n"
- "There is no folder called \"%s\" on this server.\n",
+ "Content-Type: text/plain\r\n"
+ "\r\n"
+ "There is no folder called \"%s\" on this server.\r\n",
dav_roomname
);
return;
* everything we know about (which is going to simply be the ETag and
* nothing else). Let the client-side parser sort it out.
*/
- wprintf("HTTP/1.0 207 Multi-Status\n");
+ wprintf("HTTP/1.0 207 Multi-Status\r\n");
groupdav_common_headers();
- wprintf("Content-type: text/xml\n");
+ wprintf("Content-type: text/xml\r\n");
begin_burst();
- wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
- "<D:multistatus xmlns:D=\"DAV:\">\n"
+ wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"
+ "<D:multistatus xmlns:D=\"DAV:\">\r\n"
);
serv_puts("MSGS ALL");
}
if (strlen(uid) > 0) {
- wprintf(" <D:response>\n");
+ wprintf(" <D:response>\r\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>\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: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:multistatus>\n\n\n");
+ wprintf("</D:multistatus>\r\n\r\n\r\n");
end_burst();
if (msgs != NULL) {
gotoroom(dav_roomname);
}
if (strcasecmp(WC->wc_roomname, dav_roomname)) {
- wprintf("HTTP/1.1 404 not found\n");
+ wprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
wprintf(
- "Content-Type: text/plain\n"
- "\n"
- "There is no folder called \"%s\" on this server.\n",
+ "Content-Type: text/plain\r\n"
+ "\r\n"
+ "There is no folder called \"%s\" on this server.\r\n",
dav_roomname
);
return;
if (strlen(dav_ifmatch) > 0) {
old_msgnum = locate_message_by_uid(dav_uid);
if (atol(dav_ifmatch) != old_msgnum) {
- wprintf("HTTP/1.1 412 Precondition Failed\n");
+ wprintf("HTTP/1.1 412 Precondition Failed\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
return;
}
}
serv_puts("ENT0 1|||4|||1|");
serv_gets(buf);
if (buf[0] != '8') {
- wprintf("HTTP/1.1 502 Bad Gateway\n");
+ wprintf("HTTP/1.1 502 Bad Gateway\r\n");
groupdav_common_headers();
- wprintf("Content-type: text/plain\n"
- "\n"
- "%s\n", &buf[4]
+ wprintf("Content-type: text/plain\r\n"
+ "\r\n"
+ "%s\r\n", &buf[4]
);
return;
}
/* Citadel failed in some way? */
if (new_msgnum < 0L) {
- wprintf("HTTP/1.1 502 Bad Gateway\n");
+ wprintf("HTTP/1.1 502 Bad Gateway\r\n");
groupdav_common_headers();
- wprintf("Content-type: text/plain\n"
- "\n"
- "new_msgnum is %ld\n"
- "\n", new_msgnum
+ wprintf("Content-type: text/plain\r\n"
+ "\r\n"
+ "new_msgnum is %ld\r\n"
+ "\r\n", new_msgnum
);
return;
}
/* We created this item for the first time. */
if (old_msgnum < 0L) {
- wprintf("HTTP/1.1 201 Created\n");
+ wprintf("HTTP/1.1 201 Created\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\n");
+ wprintf("Content-Length: 0\r\n");
wprintf("Location: ");
if (strlen(WC->http_host) > 0) {
wprintf("%s://%s",
}
wprintf("/groupdav/");
urlescputs(dav_roomname);
- wprintf("/%s\n", dav_uid);
- wprintf("\n");
+ wprintf("/%s\r\n", dav_uid);
+ wprintf("\r\n");
return;
}
/* We modified an existing item. */
- wprintf("HTTP/1.1 204 No Content\n");
+ wprintf("HTTP/1.1 204 No Content\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\n\n");
+ wprintf("Content-Length: 0\r\n\r\n");
/* The item we replaced has probably already been deleted by
* the Citadel server, but we'll do this anyway, just in case.
}
len = len + rlen;
}
- write(2, buf, bytes); /* FIXME */
+ /* write(2, buf, bytes); FIXME */
return (1);
}
return(count);
}
#endif
- write(2, buf, count); /* FIXME */
+ /* write(2, buf, count); FIXME */
return(write(WC->http_sock, buf, count));
}
WC->burst_len = 0;
WC->burst = NULL;
- wprintf("Content-length: %d\n\n", the_len);
+ wprintf("Content-length: %d\r\n\r\n", the_len);
client_write(the_data, the_len);
free(the_data);
}