From f8b6357914f9fb02f1b1bd4ecd8f07e637301ca3 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 5 Feb 2005 08:36:13 +0000 Subject: [PATCH] * Added an everything-buffering thingi so we can do Content-length: --- webcit/ChangeLog | 4 ++++ webcit/context_loop.c | 4 ++-- webcit/groupdav_propfind.c | 24 ++++++++++++++++-------- webcit/webcit.c | 4 ++-- webcit/webcit.h | 10 ++++++++++ webcit/webserver.c | 38 ++++++++++++++++++++++++++++++++++++-- 6 files changed, 70 insertions(+), 14 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 4e85922e2..7ac898a08 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -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 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 995393b07..387d63703 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -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 diff --git a/webcit/groupdav_propfind.c b/webcit/groupdav_propfind.c index 765a6261b..709aec435 100644 --- a/webcit/groupdav_propfind.c +++ b/webcit/groupdav_propfind.c @@ -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" - "\n" + wprintf("Content-type: text/xml\n"); + + begin_burst(); + + wprintf("\n" "\n" ); @@ -127,7 +129,9 @@ void groupdav_folder_list(void) { wprintf(" \n"); } } - wprintf("\n"); + wprintf("\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" - "\n" + wprintf("Content-type: text/xml\n"); + + begin_burst(); + + wprintf("\n" "\n" ); @@ -233,7 +239,9 @@ void groupdav_propfind(char *dav_pathname) { } } - wprintf("\n"); + wprintf("\n\n\n"); + end_burst(); + if (msgs != NULL) { free(msgs); } diff --git a/webcit/webcit.c b/webcit/webcit.c index d61817e80..7dfca75d2 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -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; diff --git a/webcit/webcit.h b/webcit/webcit.h index c15b2ff50..212a095f8 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -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 "" diff --git a/webcit/webserver.c b/webcit/webserver.c index bb5de5094..caea9ee1a 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -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 -- 2.39.2