From d7122d9b8ae8863ca4412deb95b619585f28eda6 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 13 Sep 2002 20:40:53 +0000 Subject: [PATCH] * Detect when the client browser is capable of gzip encoding (actual encoding is not implemented yet) --- webcit/ChangeLog | 5 +++++ webcit/configure.in | 16 ++++++++++++++++ webcit/context_loop.c | 23 ++++++++++++++++++++++- webcit/webcit.c | 2 +- webcit/webcit.h | 2 +- webcit/webserver.c | 1 + 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 5f51d5bac..f5efca216 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 400.3 2002/09/13 20:40:53 ajc +* Detect when the client browser is capable of gzip encoding + (actual encoding is not implemented yet) + Revision 400.2 2002/09/13 15:54:40 ajc * Reversed the above change because I broke it somehow @@ -943,3 +947,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/configure.in b/webcit/configure.in index 4f1feed60..7ae8530be 100644 --- a/webcit/configure.in +++ b/webcit/configure.in @@ -4,6 +4,8 @@ AC_INIT(webserver.c) AC_CANONICAL_HOST +AC_ARG_WITH(with_zlib, [ --with-zlib use zlib compression if present]) + dnl Set some system-specific variables which are OK to set before compiler dnl checks: PTHREAD_DEFS=-D_REENTRANT @@ -69,5 +71,19 @@ dnl AC_FUNC_VPRINTF dnl AC_CHECK_FUNCS(strerror) AC_REPLACE_FUNCS(snprintf) +dnl Checks for the zlib compression library. +if test "x$with_zlib" != xno ; then + AC_CHECK_HEADERS(zlib.h, + [AC_CHECK_LIB(z, zlibVersion, + [ok_zlib=yes],, + )]) +fi + +if test "x$ok_zlib" != xno ; then + LIBS="-lz $LIBS" + CFLAGS="-DWITH_ZLIB $CFLAGS" + AC_DEFINE(HAVE_ZLIB) +fi + AC_OUTPUT(Makefile) diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 5f67f9385..9b744f13f 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -35,6 +35,11 @@ #include #include #include + +#ifdef WITH_ZLIB +#include +#endif + #include "webcit.h" #include "webserver.h" @@ -152,6 +157,7 @@ int req_gets(int sock, char *buf, char *hold) return(0); } } + return(0); } @@ -231,6 +237,10 @@ void context_loop(int sock) int desired_session = 0; int got_cookie = 0; struct wcsession *TheSession, *sptr; + char enc[SIZ]; + char encodings[SIZ]; + int gzip = 0; + int i; /* * Find out what it is that the web browser is asking for @@ -238,12 +248,23 @@ void context_loop(int sock) memset(hold, 0, sizeof(hold)); do { if (req_gets(sock, buf, hold) < 0) return; + if (!strncasecmp(buf, "Cookie: webcit=", 15)) { cookie_to_stuff(&buf[15], &desired_session, NULL, NULL, NULL); got_cookie = 1; } + if (!strncasecmp(buf, "Accept-encoding: ", 17)) { + extract_token(encodings, &buf[17], 0, ';'); + for (i=0; ihttp_sock = sock; TheSession->lastreq = time(NULL); /* log */ - session_loop(req); /* perform the requested transaction */ + session_loop(req, gzip); /* perform the requested transaction */ pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */ /* Free the request buffer */ diff --git a/webcit/webcit.c b/webcit/webcit.c index 47b909a78..46623d1da 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -768,7 +768,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, /* * Entry point for WebCit transaction */ -void session_loop(struct httprequest *req) +void session_loop(struct httprequest *req, int gzip) { char cmd[SIZ]; char action[SIZ]; diff --git a/webcit/webcit.h b/webcit/webcit.h index a7c8363cb..a442b725e 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -285,7 +285,7 @@ void display_menubar(int); void embed_room_banner(char *); void smart_goto(char *); void worker_entry(void); -void session_loop(struct httprequest *); +void session_loop(struct httprequest *, int gzip); void fmt_date(char *buf, time_t thetime); void httpdate(char *buf, time_t thetime); void end_webcit_session(void); diff --git a/webcit/webserver.c b/webcit/webserver.c index ef7612272..7cc4f3f96 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -35,6 +35,7 @@ #include #include #include + #include "webcit.h" #include "webserver.h" -- 2.39.2