+
+void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ hdr->RawCookie = Line;
+ if (hdr->DontNeedAuth)
+ return;
+/*
+ c_username = NewStrBuf();
+ c_password = NewStrBuf();
+ c_roomname = NewStrBuf();
+ safestrncpy(c_httpauth_string, "", sizeof c_httpauth_string);
+ c_httpauth_user = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
+ c_httpauth_pass = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
+*/
+ cookie_to_stuff(Line, &hdr->desired_session,
+ hdr->c_username,
+ hdr->c_password,
+ hdr->c_roomname);
+ hdr->got_cookie = 1;
+}
+
+
+ /*
+ * Browser-based sessions use cookies for session authentication
+ * /
+ if (!isbogus &&
+ GetHash(HTTPHeaders, HKEY("COOKIE"), &vLine) &&
+ (vLine != NULL)) {
+ cookie_to_stuff(vLine, &desired_session,
+ NULL, NULL, NULL);
+ got_cookie = 1;
+ }
+ */
+ /*
+ * GroupDAV-based sessions use HTTP authentication
+ */
+/*
+ if (!isbogus &&
+ GetHash(HTTPHeaders, HKEY("AUTHORIZATION"), &vLine) &&
+ (vLine != NULL)) {
+ Line = (StrBuf*)vLine;
+ if (strncasecmp(ChrPtr(Line), "Basic", 5) == 0) {
+ StrBufCutLeft(Line, 6);
+ CtdlDecodeBase64(httpauth_string, ChrPtr(Line), StrLength(Line));
+ extract_token(httpauth_user, httpauth_string, 0, ':', sizeof httpauth_user);
+ extract_token(httpauth_pass, httpauth_string, 1, ':', sizeof httpauth_pass);
+ }
+ else
+ lprintf(1, "Authentication scheme not supported! [%s]\n", ChrPtr(Line));
+ }
+
+*/
+void Header_HandleAuth(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ const char *Pos = NULL;
+ StrBufDecodeBase64(Line);
+ StrBufExtract_NextToken(hdr->c_username, Line, &Pos, ':');
+ StrBufExtract_NextToken(hdr->c_password, Line, &Pos, ':');
+}
+
+void Header_HandleContentLength(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ hdr->ContentLength = StrToi(Line);
+}
+
+void Header_HandleContentType(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ hdr->ContentType = Line;
+}
+
+void Header_HandleUserAgent(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ hdr->user_agent = Line;
+#ifdef TECH_PREVIEW
+/* TODO: do this later on session creating
+ if ((WCC->is_mobile < 0) && is_mobile_ua(&buf[12])) {
+ WCC->is_mobile = 1;
+ }
+ else {
+ WCC->is_mobile = 0;
+ }
+*/
+#endif
+}
+
+
+void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ if ((follow_xff) && (hdr->http_host != NULL))
+ return;
+ else
+ hdr->http_host = Line;
+}
+
+void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ if (follow_xff)
+ hdr->http_host = Line;
+}
+
+
+void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ hdr->browser_host = Line;
+
+ while (StrBufNum_tokens(hdr->browser_host, ',') > 1) {
+ StrBufRemove_token(hdr->browser_host, 0, ',');
+ }
+ StrBufTrim(hdr->browser_host);
+}
+
+void Header_HandleIfModSince(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ hdr->if_modified_since = httpdate_to_timestamp(Line);
+}
+
+void Header_HandleAcceptEncoding(StrBuf *Line, ParsedHttpHdrs *hdr)
+{
+ /*
+ * Can we compress?
+ */
+ if (strstr(&ChrPtr(Line)[16], "gzip")) {
+ hdr->gzip_ok = 1;
+ }
+}
+
+/*
+{
+ c_username = NewStrBuf();
+ c_password = NewStrBuf();
+ c_roomname = NewStrBuf();
+ safestrncpy(c_httpauth_string, "", sizeof c_httpauth_string);
+ c_httpauth_user = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
+ c_httpauth_pass = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
+}
+*/
+ /* *
+ * These are the URL's which may be executed without a
+ * session cookie already set. If it's not one of these,
+ * force the session to close because cookies are
+ * probably disabled on the client browser.
+ * /
+ else if ( (StrLength(ReqLine) > 1 )
+ && (strncasecmp(ChrPtr(ReqLine), "/404", 4))
+ && (Hdr.got_cookie == 0)) {
+ StrBufPlain(ReqLine,
+ HKEY("/static/nocookies.html"
+ "?force_close_session=yes"));
+ }
+*/