X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=parsers.c;h=7dafdc72cbdbec0e68dbf26f0e6f71be7d99189a;hp=ef0fde2d78ed533665e1cb359918eb56f69d4536;hb=11a699c9045dd87513ffc486ac0e5f004fdda3bf;hpb=1cf19c9f0e26eaf18c6267bb35a059037f4ea956 diff --git a/parsers.c b/parsers.c index ef0fde2d..7dafdc72 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.196 2009/07/11 11:20:12 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.201 2009/07/19 10:06:33 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -156,6 +156,7 @@ static jb_err server_content_disposition(struct client_state *csp, char **header #ifdef FEATURE_CONNECTION_KEEP_ALIVE static jb_err server_save_content_length(struct client_state *csp, char **header); static jb_err server_keep_alive(struct client_state *csp, char **header); +static jb_err server_proxy_connection(struct client_state *csp, char **header); static jb_err client_keep_alive(struct client_state *csp, char **header); #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ @@ -230,6 +231,7 @@ static const struct parsers server_patterns[] = { #ifdef FEATURE_CONNECTION_KEEP_ALIVE { "Content-Length:", 15, server_save_content_length }, { "Keep-Alive:", 11, server_keep_alive }, + { "Proxy-Connection:", 17, server_proxy_connection }, #else { "Keep-Alive:", 11, crumble }, #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ @@ -1664,12 +1666,37 @@ static jb_err server_keep_alive(struct client_state *csp, char **header) "Server keep-alive timeout is %u. Sticking with %u.", keep_alive_timeout, csp->server_connection.keep_alive_timeout); } + csp->flags |= CSP_FLAG_SERVER_KEEP_ALIVE_TIMEOUT_SET; } return JB_ERR_OK; } +/********************************************************************* + * + * Function : server_proxy_connection + * + * Description : Figures out whether or not we should add a + * Proxy-Connection header. + * + * Parameters : + * 1 : csp = Current client state (buffers, headers, etc...) + * 2 : header = On input, pointer to header to modify. + * On output, pointer to the modified header, or NULL + * to remove the header. This function frees the + * original string if necessary. + * + * Returns : JB_ERR_OK. + * + *********************************************************************/ +static jb_err server_proxy_connection(struct client_state *csp, char **header) +{ + csp->flags |= CSP_FLAG_SERVER_PROXY_CONNECTION_HEADER_SET; + return JB_ERR_OK; +} + + /********************************************************************* * * Function : client_keep_alive @@ -1775,7 +1802,6 @@ static jb_err client_connection(struct client_state *csp, char **header) "Replaced: \'%s\' with \'%s\'", old_header, *header); freez(old_header); } - csp->flags |= CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE; } else { @@ -1785,7 +1811,18 @@ static jb_err client_connection(struct client_state *csp, char **header) *header); csp->flags &= ~CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE; } -#else + } + else if ((csp->config->feature_flags & RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE)) + { + log_error(LOG_LEVEL_HEADER, + "Keeping the client header '%s' around. " + "The server connection will be kept alive if possible.", + *header); + csp->flags |= CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE; +#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ + } + else + { char *old_header = *header; *header = strdup(connection_close); @@ -1796,18 +1833,7 @@ static jb_err client_connection(struct client_state *csp, char **header) log_error(LOG_LEVEL_HEADER, "Replaced: \'%s\' with \'%s\'", old_header, *header); freez(old_header); -#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ } -#ifdef FEATURE_CONNECTION_KEEP_ALIVE - else - { - log_error(LOG_LEVEL_HEADER, - "Keeping the client header '%s' around. " - "The server connection will be kept alive if possible.", - *header); - csp->flags |= CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE; - } -#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ /* Signal client_connection_adder() to return early. */ csp->flags |= CSP_FLAG_CLIENT_CONNECTION_HEADER_SET; @@ -3531,7 +3557,8 @@ static jb_err server_proxy_connection_adder(struct client_state *csp) jb_err err = JB_ERR_OK; if ((csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE) - && !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)) + && !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED) + && !(csp->flags & CSP_FLAG_SERVER_PROXY_CONNECTION_HEADER_SET)) { log_error(LOG_LEVEL_HEADER, "Adding: %s", proxy_connection_header); err = enlist(csp->headers, proxy_connection_header);