* Added an everything-buffering thingi so we can do Content-length:
authorArt Cancro <ajc@citadel.org>
Sat, 5 Feb 2005 08:36:13 +0000 (08:36 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 5 Feb 2005 08:36:13 +0000 (08:36 +0000)
webcit/ChangeLog
webcit/context_loop.c
webcit/groupdav_propfind.c
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c

index 4e85922e29653e0df772d6f22c38f6d3d041758a..7ac898a081a2a851f2bc763e83789bd26f06ee8b 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 528.43  2005/02/05 08:36:13  ajc
+* Added an everything-buffering thingi so we can do Content-length:
+
 Revision 528.42  2005/02/05 04:16:01  ajc
 * Cleanup of new message range view-o-matic
 * GroupDAV GET operations now only send the Content-type: and Date:
@@ -2317,3 +2320,4 @@ 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 995393b074249556716ba992d2aa85b46830ac77..387d63703e333b1c9b2ef79e498c2d535f398351 100644 (file)
@@ -267,8 +267,8 @@ void context_loop(int sock)
        char httpauth_pass[SIZ];
 
        strcpy(httpauth_string, "");
-       strcpy(httpauth_user, "");
-       strcpy(httpauth_pass, "");
+       strcpy(httpauth_user, DEFAULT_HTTPAUTH_USER);
+       strcpy(httpauth_pass, DEFAULT_HTTPAUTH_PASS);
 
        /*
         * Find out what it is that the web browser is asking for
index 765a6261b94ba08a1f2971d9e3cdca0cba8f0641..709aec43515d6faa7c3a4b9e5bd3417deb5b72c0 100644 (file)
@@ -69,9 +69,11 @@ void groupdav_folder_list(void) {
         */
        wprintf("HTTP/1.0 207 Multi-Status\n");
        groupdav_common_headers();
-       wprintf("Content-type: text/xml\n"
-               "\n"
-               "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+       wprintf("Content-type: text/xml\n");
+
+       begin_burst();
+
+       wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                "<D:multistatus xmlns:D=\"DAV:\">\n"
        );
 
@@ -127,7 +129,9 @@ void groupdav_folder_list(void) {
                        wprintf(" </D:response>\n");
                }
        }
-       wprintf("</D:multistatus>\n");
+       wprintf("</D:multistatus>\n\n\n");
+
+       end_burst();
 }
 
 
@@ -188,9 +192,11 @@ void groupdav_propfind(char *dav_pathname) {
         */
        wprintf("HTTP/1.0 207 Multi-Status\n");
        groupdav_common_headers();
-       wprintf("Content-type: text/xml\n"
-               "\n"
-               "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+       wprintf("Content-type: text/xml\n");
+
+       begin_burst();
+
+       wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                "<D:multistatus xmlns:D=\"DAV:\">\n"
        );
 
@@ -233,7 +239,9 @@ void groupdav_propfind(char *dav_pathname) {
                }
        }
 
-       wprintf("</D:multistatus>\n");
+       wprintf("</D:multistatus>\n\n\n");
+       end_burst();
+
        if (msgs != NULL) {
                free(msgs);
        }
index d61817e8031c61e7b451dfffa8673fe73d079140..7dfca75d200929331129a7090b00285c6e0ce996 100644 (file)
@@ -850,8 +850,8 @@ void session_loop(struct httprequest *req)
        strcpy(c_password, "");
        strcpy(c_roomname, "");
        strcpy(c_httpauth_string, "");
-       strcpy(c_httpauth_user, "");
-       strcpy(c_httpauth_pass, "");
+       strcpy(c_httpauth_user, DEFAULT_HTTPAUTH_USER);
+       strcpy(c_httpauth_pass, DEFAULT_HTTPAUTH_PASS);
 
        WC->upload_length = 0;
        WC->upload = NULL;
index c15b2ff508fcadef343a42dad14df93bdeec067f..212a095f8ccef6d8c4a74e5fe332c999da05c5ff 100644 (file)
@@ -230,6 +230,9 @@ struct wcsession {
        int ctdl_pid;                   /* Session ID on the Citadel server */
        char httpauth_user[SIZ];        /* only for GroupDAV sessions */
        char httpauth_pass[SIZ];        /* only for GroupDAV sessions */
+
+       size_t burst_len;
+       char *burst;
 };
 
 #define extract(dest,source,parmnum)   extract_token(dest,source,parmnum,'|')
@@ -486,6 +489,9 @@ int client_read_ssl(char *buf, int bytes, int timeout);
 void client_write_ssl(char *buf, int nbytes);
 #endif
 
+void begin_burst(void);
+void end_burst(void);
+
 extern char *ascmonths[];
 
 
@@ -497,3 +503,7 @@ extern char *ascmonths[];
 #define VIEW_TASKS             4       /* Tasks view */
 #define VIEW_NOTES             5       /* Notes view */
 
+
+/* These should be empty, but we have them for testing */
+#define DEFAULT_HTTPAUTH_USER  ""
+#define DEFAULT_HTTPAUTH_PASS  ""
index bb5de5094e62d48eab459afa0a3c97ab39eef1de..caea9ee1a5acb89a194db5cbb73bc04a052a7c28 100644 (file)
@@ -150,23 +150,57 @@ 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);
 }
 
 
 ssize_t client_write(const void *buf, size_t count) {
+
+       if (WC->burst != NULL) {
+               WC->burst = realloc(WC->burst, (WC->burst_len + count + 2));
+               memcpy(&WC->burst[WC->burst_len], buf, count);
+               WC->burst_len += count;
+               return(count);
+       }
+
 #ifdef HAVE_OPENSSL
        if (is_https) {
                client_write_ssl((char *)buf, count);
                return(count);
        }
 #endif
-       /* write(2, buf, count);  FIXME */
+       write(2, buf, count); /* FIXME */
        return(write(WC->http_sock, buf, count));
 }
 
 
+void begin_burst(void) {
+       if (WC->burst != NULL) {
+               free(WC->burst);
+               WC->burst = NULL;
+       }
+       WC->burst_len = 0;
+       WC->burst = malloc(SIZ);
+}
+
+void end_burst(void) {
+       size_t the_len;
+       char *the_data;
+
+       the_len = WC->burst_len;
+       the_data = WC->burst;
+
+       WC->burst_len = 0;
+       WC->burst = NULL;
+
+       wprintf("Content-length: %d\n\n", the_len);
+       client_write(the_data, the_len);
+       free(the_data);
+}
+
+
+
 /*
  * Read data from the client socket with default timeout.
  * (This is implemented in terms of client_read_to() and could be