]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
* do linebuffered reading from server
[citadel.git] / webcit / webcit.c
index edc19a0c6422ec9079ed8edd56833871d90a4b65..8647deec2b3fc7aefb5a8b24963b41b4b5462ebb 100644 (file)
@@ -116,12 +116,17 @@ void output_headers(      int do_httpheaders,     /* 1 = output HTTP headers
        http_datestring(httpnow, sizeof httpnow, time(NULL));
 
        if (do_httpheaders) {
-               hprintf("Content-type: text/html; charset=utf-8\r\n"
-                       "Server: %s / %s\n"
-                       "Connection: close\r\n",
-                       PACKAGE_STRING, 
-                       ChrPtr(WCC->serv_info->serv_software)
-               );
+               if (WCC->serv_info != NULL)
+                       hprintf("Content-type: text/html; charset=utf-8\r\n"
+                               "Server: %s / %s\n"
+                               "Connection: close\r\n",
+                               PACKAGE_STRING, 
+                               ChrPtr(WCC->serv_info->serv_software));
+               else
+                       hprintf("Content-type: text/html; charset=utf-8\r\n"
+                               "Server: %s / [n/a]\n"
+                               "Connection: close\r\n",
+                               PACKAGE_STRING);
        }
 
        if (cache) {
@@ -603,7 +608,6 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
                index[a] = arg[a-1];
                sizes[a] = sizeof arg[a-1];
        }
-/*///  index[9] = &foo; todo */
        nBackDots = 0;
        nEmpty = 0;
        for ( a = 0; a < 9; ++a)
@@ -628,12 +632,9 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
        }
        if (GetHash(HTTPHeaders, HKEY("AUTHORIZATION"), &vLine) &&
            (vLine!=NULL)) {
-/* TODO: wrap base64 in strbuf */
-               CtdlDecodeBase64(c_httpauth_string, ChrPtr((StrBuf*)vLine), StrLength((StrBuf*)vLine));
-               FlushStrBuf(Buf);
-               StrBufAppendBufPlain(Buf, c_httpauth_string, -1, 0);
-               StrBufExtract_token(c_httpauth_user, Buf, 0, ':');
-               StrBufExtract_token(c_httpauth_pass, Buf, 1, ':');
+               StrBufDecodeBase64((StrBuf*)vLine);
+               StrBufExtract_token(c_httpauth_user, (StrBuf*)vLine, 0, ':');
+               StrBufExtract_token(c_httpauth_pass, (StrBuf*)vLine, 1, ':');
        }
        if (GetHash(HTTPHeaders, HKEY("CONTENT-LENGTH"), &vLine) &&
            (vLine!=NULL)) {
@@ -787,6 +788,7 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
         * connection now.
         */
        if (!WCC->connected) {
+               WCC->ReadBuf = NewStrBuf();
                if (!strcasecmp(ctdlhost, "uds")) {
                        /* unix domain socket */
                        snprintf(buf, SIZ, "%s/citadel.socket", ctdlport);
@@ -827,8 +829,8 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
                                }
                                locate_host(browser_host, WCC->http_sock);
                        }
-
-                       WCC->serv_info = get_serv_info(browser_host, user_agent);
+                       if (WCC->serv_info == NULL)
+                               WCC->serv_info = get_serv_info(browser_host, user_agent);
                        if (WCC->serv_info->serv_rev_level < MINIMUM_CIT_VERSION) {
                                begin_burst();
                                wprintf(_("You are connected to a Citadel "
@@ -847,7 +849,7 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
                        }
                }
        }
-/*///////todo: restore language in this case */
+
        /*
         * Functions which can be performed without logging in
         */
@@ -949,12 +951,7 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
                        serv_printf("PASS %s", ChrPtr(c_password));
                        StrBuf_ServGetln(Buf);
                        if (GetServerStatus(Buf, NULL) == 2) {
-                               StrBuf *Lang;
                                become_logged_in(c_username, c_password, Buf);
-                               if (get_preference("language", &Lang)) {
-                                       set_selected_language(ChrPtr(Lang));
-                                       go_selected_language();         /* set locale */
-                               }
                                get_preference("default_header_charset", &WCC->DefaultCharset);
                        }
                }