From fbd3a80cd8078c22255514013d321c56759807b8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 7 May 2000 23:46:55 +0000 Subject: [PATCH] * added Date: and Last-Modified: headers to HTTP output * masquerade room/host screen now runs in wholist window, and returns to it --- webcit/ChangeLog | 5 +++++ webcit/tools.c | 44 +++++++++++++++++++++++++++++++++++++++----- webcit/webcit.c | 13 +++++++++++++ webcit/webcit.h | 1 + webcit/who.c | 5 +++-- 5 files changed, 61 insertions(+), 7 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 1075ca42a..16a9f99e7 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 211.17 2000/05/07 23:46:55 ajc +* added Date: and Last-Modified: headers to HTTP output +* masquerade room/host screen now runs in wholist window, and returns to it + Revision 211.16 2000/05/02 17:32:06 ajc * Font related changes to html @@ -431,3 +435,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/tools.c b/webcit/tools.c index 9216105fc..d8204f93e 100644 --- a/webcit/tools.c +++ b/webcit/tools.c @@ -27,6 +27,14 @@ #include "webcit.h" +char *ascmonths[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +}; + +char *ascdays[] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; char *safestrncpy(char *dest, const char *src, size_t n) @@ -139,11 +147,6 @@ char ch; void fmt_date(char *buf, time_t thetime) { struct tm *tm; - char *ascmonths[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - strcpy(buf, ""); tm = localtime(&thetime); @@ -156,3 +159,34 @@ void fmt_date(char *buf, time_t thetime) { ( (tm->tm_hour > 12) ? "pm" : "am" ) ); } + + + + +/* + * Format a date/time stamp to the format used in HTTP headers + */ +void httpdate(char *buf, time_t thetime) { + struct tm *tm; + + strcpy(buf, ""); + tm = localtime(&thetime); + + sprintf(buf, "%s, %02d %s %4d %02d:%02d:%02d", + ascdays[tm->tm_wday], + tm->tm_mday, + ascmonths[tm->tm_mon], + tm->tm_year + 1900, + tm->tm_hour, + tm->tm_min, + tm->tm_sec + ); +} + + + + + + + + diff --git a/webcit/webcit.c b/webcit/webcit.c index e7d0047ff..72da8375e 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -289,18 +289,23 @@ void output_headers(int controlcode) char cookie[256]; int print_standard_html_head = 0; int refresh30 = 0; + char httpnow[256]; print_standard_html_head = controlcode & 0x03; refresh30 = ((controlcode & 0x04) >> 2); wprintf("HTTP/1.0 200 OK\n"); + httpdate(httpnow, time(NULL)); + if (print_standard_html_head > 0) { wprintf("Content-type: text/html\n"); wprintf("Server: %s\n", SERVER); wprintf("Connection: close\n"); wprintf("Pragma: no-cache\n"); wprintf("Cache-Control: no-store\n"); + wprintf("Date: %s\n" + "Last-modified: %s\n", httpnow, httpnow); } stuff_to_cookie(cookie, WC->wc_session, WC->wc_username, WC->wc_password, WC->wc_roomname); @@ -398,6 +403,7 @@ void check_for_express_messages() void output_static(char *what) { char buf[4096]; + char datebuf[256]; long thisblock; FILE *fp; struct stat statbuf; @@ -428,6 +434,13 @@ void output_static(char *what) bytes = statbuf.st_size; fprintf(stderr, "Static: %s, %ld bytes\n", what, bytes); wprintf("Content-length: %ld\n", (long) bytes); + + httpdate(datebuf, time(NULL)); + wprintf("Date: %s\n", datebuf); + + httpdate(datebuf, statbuf.st_mtime); + wprintf("Last-modified: %s\n", datebuf); + wprintf("\n"); while (bytes > 0) { thisblock = sizeof(buf); diff --git a/webcit/webcit.h b/webcit/webcit.h index bdb0a081d..72873a1f0 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -257,4 +257,5 @@ void mime_parser(char *content, void *cbcontent, char *cbtype, size_t cblength) ); void fmt_date(char *buf, time_t thetime); +void httpdate(char *buf, time_t thetime); void end_webcit_session(void); diff --git a/webcit/who.c b/webcit/who.c index b172f6b15..8fa8ed8ff 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -124,7 +124,7 @@ void whobbs(void) } if (wlist->sessionnum == serv_info.serv_pid) { wprintf(" (edit)"); + ">(edit)"); } /* username */ wprintf("\n\t"); @@ -145,6 +145,7 @@ void whobbs(void) wprintf("\n\n
\n"); wprintf("Close window\n"); wprintf("
\n"); + wDumpContent(1); } @@ -183,7 +184,7 @@ void edit_me(void) whobbs(); } else { - output_headers(1); + output_headers(3); wprintf("
"); wprintf(""); -- 2.39.2