From: Fabian Keil Date: Sat, 24 Nov 2012 14:06:18 +0000 (+0000) Subject: Allow HTTP/1.0 clients to signal interest in keep-alive through the Proxy-Connection... X-Git-Tag: v_3_0_20~162 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=9a962b219983489e778f24d95e1d6b3ddb8c7a87 Allow HTTP/1.0 clients to signal interest in keep-alive through the Proxy-Connection header While such client are rare in the real world, it doesn't hurt and couple of curl tests rely on it. --- diff --git a/parsers.c b/parsers.c index a785d824..37737a74 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.265 2012/11/24 13:57:30 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.266 2012/11/24 13:58:17 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -137,6 +137,7 @@ 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); static jb_err client_save_content_length(struct client_state *csp, char **header); +static jb_err client_proxy_connection(struct client_state *csp, char **header); #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ static jb_err client_host_adder (struct client_state *csp); @@ -184,11 +185,12 @@ static const struct parsers client_patterns[] = { #ifdef FEATURE_CONNECTION_KEEP_ALIVE { "Keep-Alive:", 11, client_keep_alive }, { "Content-Length:", 15, client_save_content_length }, + { "Proxy-Connection:", 17, client_proxy_connection }, #else { "Keep-Alive:", 11, crumble }, + { "Proxy-Connection:", 17, crumble }, #endif { "connection:", 11, client_connection }, - { "proxy-connection:", 17, crumble }, { "max-forwards:", 13, client_max_forwards }, { "Accept-Language:", 16, client_accept_language }, { "if-none-match:", 14, client_if_none_match }, @@ -1940,6 +1942,42 @@ static jb_err client_connection(struct client_state *csp, char **header) } +#ifdef FEATURE_CONNECTION_KEEP_ALIVE +/********************************************************************* + * + * Function : client_proxy_connection + * + * Description : Sets the CLIENT_CONNECTION_KEEP_ALIVE flag when + * appropriate and removes the 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 client_proxy_connection(struct client_state *csp, char **header) +{ + if (0 == (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE) + && (csp->http->ssl == 0) + && (NULL == strstr(*header, "close"))) + { + log_error(LOG_LEVEL_HEADER, + "The client connection can be kept alive due to: %s", *header); + csp->flags |= CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE; + } + crumble(csp, header); + + return JB_ERR_OK; +} +#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ + + /********************************************************************* * * Function : crumble