]> code.citadel.org Git - citadel.git/blobdiff - webcit/context_loop.c
* Finished gzip compression of dynamic pages (when browser supports it)
[citadel.git] / webcit / context_loop.c
index e979beeb8b17a9fe911df0f8b86b4183c19a06c9..3a9a29178d9dc1fdc604139a72d738c889fdeb5e 100644 (file)
@@ -63,6 +63,8 @@ void do_housekeeping(void)
                        /* Remove sessions flagged for kill */
                        if (sptr->killthis) {
 
+                               lprintf(3, "Destroying session\n");
+
                                /* remove session from linked list */
                                if (sptr == SessionList) {
                                        SessionList = SessionList->next;
@@ -150,6 +152,7 @@ int req_gets(int sock, char *buf, char *hold)
                                return(0);
                        }
        }
+
        return(0);
 }
 
@@ -229,6 +232,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
@@ -236,12 +243,25 @@ 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;
                }
 
+#ifdef WITH_ZLIB
+               if (!strncasecmp(buf, "Accept-encoding: ", 17)) {
+                       extract_token(encodings, &buf[17], 0, ';');
+                       for (i=0; i<num_tokens(encodings, ','); ++i) {
+                               extract_token(enc, encodings, i, ',');
+                               if (!strcasecmp(enc, "gzip")) {
+                                       gzip = 1;
+                               }
+                       }
+               }
+#endif
+
                hptr = (struct httprequest *)
                        malloc(sizeof(struct httprequest));
                if (req == NULL)
@@ -268,6 +288,7 @@ void context_loop(int sock)
         */
        if (!strncasecmp(buf, "GET ", 4)) strcpy(buf, &buf[4]);
        else if (!strncasecmp(buf, "HEAD ", 5)) strcpy(buf, &buf[5]);
+       else if (!strncasecmp(buf, "POST ", 5)) strcpy(buf, &buf[5]);
        if (buf[1]==' ') buf[1]=0;
 
        /*
@@ -280,7 +301,9 @@ void context_loop(int sock)
        }
 
        /* Do the non-root-cookie check now. */
-       else if ( (strcmp(buf, "/")) && (got_cookie == 0)) {
+       else if ( (strcmp(buf, "/"))
+               && (strncasecmp(buf, "/listsub", 8))
+               && (got_cookie == 0)) {
                strcpy(req->line, "GET /static/nocookies.html"
                                "?force_close_session=yes HTTP/1.0");
        }
@@ -317,14 +340,11 @@ void context_loop(int sock)
                pthread_mutex_unlock(&SessionListMutex);
        }
 
-
        /*
-        *
-        * FIX ... check session integrity here before continuing
-        *
+        * A future improvement might be to check the session integrity
+        * at this point before continuing.
         */
 
-
        /*
         * Bind to the session and perform the transaction
         */
@@ -332,7 +352,7 @@ void context_loop(int sock)
        pthread_setspecific(MyConKey, (void *)TheSession);
        TheSession->http_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 */