From 7ffbb198748dcedda412765d276d5e0ca08fd903 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 18 Jul 2009 12:20:05 +0000 Subject: [PATCH] Don't add a Proxy-Connection header if there already is one. --- parsers.c | 31 +++++++++++++++++++++++++++++-- project.h | 8 +++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/parsers.c b/parsers.c index ca0eb5c6..6803e359 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.197 2009/07/13 17:10:57 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.198 2009/07/14 17:50:34 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 */ @@ -1671,6 +1673,30 @@ static jb_err server_keep_alive(struct client_state *csp, char **header) } +/********************************************************************* + * + * 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 @@ -3532,7 +3558,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); diff --git a/project.h b/project.h index 6e24ed2c..f30f4bbc 100644 --- a/project.h +++ b/project.h @@ -1,7 +1,7 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED /** Version string. */ -#define PROJECT_H_VERSION "$Id: project.h,v 1.146 2009/07/14 17:45:05 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.147 2009/07/14 17:50:34 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -782,6 +782,12 @@ struct reusable_connection */ #define CSP_FLAG_SERVER_SOCKET_TAINTED 0x00040000U +/** + * Flag for csp->flags: Set if the Proxy-Connection header + * is among the server headers. + */ +#define CSP_FLAG_SERVER_PROXY_CONNECTION_HEADER_SET 0x00080000U + /* * Flags for use in return codes of child processes */ -- 2.49.0