X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=parsers.c;h=b2b708586df62da4b78b9f64a59f2729c90a78fc;hb=2f2dc770ce36518e4f29585a9ce181bbe29dab7e;hp=c03a0902572de71aaa545ee124ae6ab247db6594;hpb=92b3f9f61301728983a79cb367a85b00a3439e16;p=privoxy.git diff --git a/parsers.c b/parsers.c index c03a0902..b2b70858 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.164 2009/05/25 15:42:40 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.167 2009/05/28 21:13:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -2230,7 +2230,6 @@ static jb_err server_last_modified(struct client_state *csp, char **header) #endif struct tm *timeptr = NULL; time_t now, last_modified; - long int rtime; long int days, hours, minutes, seconds; /* @@ -2280,7 +2279,7 @@ static jb_err server_last_modified(struct client_state *csp, char **header) now = time(NULL); #ifdef HAVE_GMTIME_R gmtime_r(&now, &gmt); -#elif def MUTEX_LOCKS_AVAILABLE +#elif defined(MUTEX_LOCKS_AVAILABLE) privoxy_mutex_lock(&gmtime_mutex); gmtime(&now); privoxy_mutex_unlock(&gmtime_mutex); @@ -2294,23 +2293,25 @@ static jb_err server_last_modified(struct client_state *csp, char **header) } else { - rtime = (long int)difftime(now, last_modified); + long int rtime = (long int)difftime(now, last_modified); if (rtime) { - int negative = 0; + const int negative_delta = (rtime < 0); - if (rtime < 0) + if (negative_delta) { rtime *= -1; - negative = 1; log_error(LOG_LEVEL_HEADER, "Server time in the future."); } rtime = pick_from_range(rtime); - if (negative) rtime *= -1; + if (negative_delta) + { + rtime *= -1; + } last_modified += rtime; #ifdef HAVE_GMTIME_R timeptr = gmtime_r(&last_modified, &gmt); -#elif def MUTEX_LOCKS_AVAILABLE +#elif defined(MUTEX_LOCKS_AVAILABLE) privoxy_mutex_lock(&gmtime_mutex); timeptr = gmtime(&last_modified); privoxy_mutex_unlock(&gmtime_mutex); @@ -3030,7 +3031,7 @@ static jb_err client_if_modified_since(struct client_state *csp, char **header) tm += rtime * (negative ? -1 : 1); #ifdef HAVE_GMTIME_R timeptr = gmtime_r(&tm, &gmt); -#elif def MUTEX_LOCKS_AVAILABLE +#elif defined(MUTEX_LOCKS_AVAILABLE) privoxy_mutex_lock(&gmtime_mutex); timeptr = gmtime(&tm); privoxy_mutex_unlock(&gmtime_mutex); @@ -3389,7 +3390,8 @@ static jb_err server_connection_adder(struct client_state *csp) * Function : server_proxy_connection_adder * * Description : Adds a "Proxy-Connection: keep-alive" header to - * csp->headers. XXX: We should reuse existant ones. + * csp->headers if the client asked for keep-alive. + * XXX: We should reuse existant ones. * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) @@ -3401,8 +3403,15 @@ static jb_err server_connection_adder(struct client_state *csp) static jb_err server_proxy_connection_adder(struct client_state *csp) { static const char proxy_connection_header[] = "Proxy-Connection: keep-alive"; - log_error(LOG_LEVEL_HEADER, "Adding: %s", proxy_connection_header); - return enlist(csp->headers, proxy_connection_header); + jb_err err = JB_ERR_OK; + + if ((csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE)) + { + log_error(LOG_LEVEL_HEADER, "Adding: %s", proxy_connection_header); + err = enlist(csp->headers, proxy_connection_header); + } + + return err; } #endif /* FEATURE_CONNECTION_KEEP_ALIVE */