*
*/
-#include <ctype.h>
-#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <pthread.h>
-#include <signal.h>
#include "webcit.h"
#include "webserver.h"
pthread_mutex_unlock(&sessions_to_kill->SessionMutex);
sptr = sessions_to_kill->next;
free(sessions_to_kill);
- sessions_to_kill = sessions_to_kill->next;
+ sessions_to_kill = sptr;
--num_sessions;
}
char buf[SIZ], hold[SIZ];
int desired_session = 0;
int got_cookie = 0;
+ int gzip_ok = 0;
struct wcsession *TheSession, *sptr;
char httpauth_string[SIZ];
char httpauth_user[SIZ];
do {
if (req_gets(sock, buf, hold) < 0) return;
+ /*
+ * Can we compress?
+ */
+ if (!strncasecmp(buf, "Accept-encoding:", 16)) {
+ if (strstr(&buf[16], "gzip")) {
+ gzip_ok = 1;
+ }
+ }
+
/*
* Browser-based sessions use cookies for session authentication
*/
if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
cookie_to_stuff(&buf[15], &desired_session,
- NULL, NULL, NULL);
+ NULL, 0, NULL, 0, NULL, 0);
got_cookie = 1;
}
*/
if (!strncasecmp(buf, "Authorization: Basic ", 21)) {
CtdlDecodeBase64(httpauth_string, &buf[21], strlen(&buf[21]));
- extract_token(httpauth_user, httpauth_string, 0, ':');
- extract_token(httpauth_pass, httpauth_string, 1, ':');
+ extract_token(httpauth_user, httpauth_string, 0, ':', sizeof httpauth_user);
+ extract_token(httpauth_pass, httpauth_string, 1, ':', sizeof httpauth_pass);
+ }
+
+ if (!strncasecmp(buf, "If-Modified-Since: ", 19)) {
+ if_modified_since = httpdate_to_timestamp(&buf[19]);
}
/*
*/
if (!strncasecmp(buf, "/robots.txt", 11)) {
strcpy(req->line, "GET /static/robots.txt"
- "?force_close_session=yes HTTP/1.0");
+ "?force_close_session=yes HTTP/1.1");
}
else if (!strncasecmp(buf, "/favicon.ico", 12)) {
strcpy(req->line, "GET /static/favicon.ico");
&& (strncasecmp(buf, "/freebusy", 9))
&& (strncasecmp(buf, "/do_logout", 10))
&& (strncasecmp(buf, "/groupdav", 9))
+ && (strncasecmp(buf, "/rss", 4))
&& (got_cookie == 0)) {
strcpy(req->line, "GET /static/nocookies.html"
- "?force_close_session=yes HTTP/1.0");
+ "?force_close_session=yes HTTP/1.1");
}
/*
/*
* Bind to the session and perform the transaction
*/
- lprintf(9, "LOCKING SESSION %d\n", TheSession->wc_session);
pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
- lprintf(9, "LOCKKED SESSION %d\n", TheSession->wc_session);
pthread_setspecific(MyConKey, (void *)TheSession);
TheSession->http_sock = sock;
TheSession->lastreq = time(NULL); /* log */
+ TheSession->gzip_ok = gzip_ok;
session_loop(req); /* do transaction */
- lprintf(9, "UNLKING SESSION %d\n", TheSession->wc_session);
pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */
/* Free the request buffer */