Enable sharing of server connections again, even if the client doesn't support keep...
[privoxy.git] / parsers.c
index 6e9645e..36a819f 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.230 2011/09/04 11:32:20 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.234 2011/10/08 17:31:51 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -1850,6 +1850,15 @@ static jb_err client_connection(struct client_state *csp, char **header)
              log_error(LOG_LEVEL_HEADER,
                 "Removing \'%s\' to imply keep-alive.", *header);
              freez(*header);
+             /*
+              * While we imply keep-alive to the server,
+              * we have to remember that the client didn't.
+              *
+              * XXX: The implied keep-alive currently doesn't
+              *      actually work due to a not yet properly
+              *      analyzed regression in chat()
+              */
+             csp->flags &= ~CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE;
           }
           else
           {
@@ -2468,7 +2477,6 @@ static jb_err server_content_disposition(struct client_state *csp, char **header
 static jb_err server_last_modified(struct client_state *csp, char **header)
 {
    const char *newval;
-   char buf[BUFFER_SIZE];
    time_t last_modified;
    char newheader[50];
 
@@ -2497,6 +2505,7 @@ static jb_err server_last_modified(struct client_state *csp, char **header)
       /*
        * Setting Last-Modified Header to now.
        */
+      char buf[30];
       get_http_time(0, buf, sizeof(buf));
       freez(*header);
       *header = strdup("Last-Modified: ");
@@ -4013,7 +4022,7 @@ static jb_err parse_header_time(const char *header_time, time_t *result)
     * attempt to work around GNU libc's strptime()
     * reporting negative year values when using %Y.
     */
-   static const char *time_formats[] = {
+   static const char * const time_formats[] = {
       /* Tue, 02-Jun-37 20:00:00 */
       "%a, %d-%b-%y %H:%M:%S",
       /* Tue, 02 Jun 2037 20:00:00 */
@@ -4027,14 +4036,14 @@ static jb_err parse_header_time(const char *header_time, time_t *result)
    };
    unsigned int i;
 
-   /*
-    * Zero out gmt to prevent time zone offsets.
-    * Documented to be required for GNU libc.
-    */
-   memset(&gmt, 0, sizeof(gmt));
-
    for (i = 0; i < SZ(time_formats); i++)
    {
+      /*
+       * Zero out gmt to prevent time zone offsets.
+       * Documented to be required for GNU libc.
+       */
+      memset(&gmt, 0, sizeof(gmt));
+
       if (NULL != strptime(header_time, time_formats[i], &gmt))
       {
          /* Sanity check for GNU libc. */