]> code.citadel.org Git - citadel.git/commitdiff
* All GroupDAV HTTP output is now \r\n instead of \n terminated.
authorArt Cancro <ajc@citadel.org>
Sat, 5 Feb 2005 22:58:46 +0000 (22:58 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 5 Feb 2005 22:58:46 +0000 (22:58 +0000)
webcit/ChangeLog
webcit/groupdav_delete.c
webcit/groupdav_get.c
webcit/groupdav_main.c
webcit/groupdav_propfind.c
webcit/groupdav_put.c
webcit/webserver.c

index 7ac898a081a2a851f2bc763e83789bd26f06ee8b..f52a1b48877b8527f7fd65e7873da8c06babb05e 100644 (file)
@@ -1,4 +1,7 @@
 $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:
 
@@ -2320,4 +2323,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index c75fcd90fa048b9154076f46808ea89abc653297..16991b53740823f1be1100d5eabc1c80ba79aeb9 100644 (file)
@@ -34,7 +34,6 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
        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 */
@@ -57,9 +56,9 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
                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;
        }
 
@@ -69,9 +68,9 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
         * 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;
        }
 
@@ -81,9 +80,9 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
         */
        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;
                }
        }
@@ -94,14 +93,14 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
        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;
 }
index 66bcb16268f588ab22a4111a7446f49dcbd5bf3b..dafcc7653857d09f71fbd4c19c4354884239d2b9 100644 (file)
@@ -58,12 +58,12 @@ void groupdav_get(char *dav_pathname) {
                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;
@@ -73,37 +73,37 @@ void groupdav_get(char *dav_pathname) {
        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);
                }
        }
 }
index 5d409440d5142dec0a296a599621567d13bc7860..92d913134447335555e34a7d76ad717024c3d9b4 100644 (file)
@@ -31,8 +31,8 @@
  */
 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
        );
 }
@@ -136,11 +136,11 @@ void groupdav_main(struct httprequest *req,
        }
 
        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;
        }
 
@@ -201,11 +201,11 @@ void groupdav_main(struct httprequest *req,
        /*
         * 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
        );
 }
index 709aec43515d6faa7c3a4b9e5bd3417deb5b72c0..d0f3f7f65bd6dcffd65c8a177ad084fd51f09cb9 100644 (file)
@@ -67,14 +67,14 @@ void groupdav_folder_list(void) {
         * 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");
@@ -91,7 +91,7 @@ void groupdav_folder_list(void) {
                 */
                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) {
@@ -101,35 +101,35 @@ void groupdav_folder_list(void) {
                        }
                        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();
 }
@@ -174,12 +174,12 @@ void groupdav_propfind(char *dav_pathname) {
                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;
@@ -190,14 +190,14 @@ void groupdav_propfind(char *dav_pathname) {
         * 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");
@@ -219,7 +219,7 @@ void groupdav_propfind(char *dav_pathname) {
                }
 
                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",
@@ -230,16 +230,16 @@ void groupdav_propfind(char *dav_pathname) {
                        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) {
index 3a92de8207e7e34929bf6abfaace28984bd36b1f..9825537c31539f3618823a27fa25b329685d5b70 100644 (file)
@@ -60,12 +60,12 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
                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;
@@ -100,9 +100,9 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
        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;
                }
        }
@@ -115,11 +115,11 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
        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;
        }
@@ -149,21 +149,21 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
 
        /* 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",
@@ -172,15 +172,15 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
                }
                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.
index caea9ee1a5acb89a194db5cbb73bc04a052a7c28..86d2a237a3293d4a4c8c9026e14939b2cd62cc80 100644 (file)
@@ -150,7 +150,7 @@ int client_read_to(int sock, char *buf, int bytes, int timeout)
                }
                len = len + rlen;
        }
-       write(2, buf, bytes); /* FIXME */
+       /* write(2, buf, bytes); FIXME */
        return (1);
 }
 
@@ -170,7 +170,7 @@ ssize_t client_write(const void *buf, size_t count) {
                return(count);
        }
 #endif
-       write(2, buf, count); /* FIXME */
+       /* write(2, buf, count); FIXME */
        return(write(WC->http_sock, buf, count));
 }
 
@@ -194,7 +194,7 @@ void end_burst(void) {
        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);
 }