[Privoxy-commits] [privoxy] 02/09: Look for the "keep-alive" keyword more carefully
User Git
git at git.privoxy.org
Wed Jun 18 05:46:59 CEST 2025
This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository privoxy.
commit d34d4df1ee741844a53c2bfaf36b5f60fd165e62
Author: Fabian Keil <fk at fabiankeil.de>
AuthorDate: Sat Feb 8 13:55:15 2025 +0100
Look for the "keep-alive" keyword more carefully
... in Connection headers. Previously connections were not
kept alive if the Connection header contained additional
keywords like "Upgrade".
---
parsers.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/parsers.c b/parsers.c
index a14f970d..5428a445 100644
--- a/parsers.c
+++ b/parsers.c
@@ -1791,6 +1791,51 @@ static jb_err filter_header(struct client_state *csp, char **header)
}
+/*********************************************************************
+ *
+ * Function : connection_header_contains_keep_alive_keyword
+ *
+ * Description : Checks wether or not a Connection header contains
+ * the keep-alive keyword.
+ *
+ * Parameters :
+ * 1 : header = The Connection header to check.
+ *
+ * Returns : TRUE or FALSE.
+ *
+ *********************************************************************/
+static int connection_header_contains_keep_alive_keyword(const char *header)
+{
+ char *header_content;
+ char *keywords[4];
+ int segments;
+ int keep_alive_keyword_present = FALSE;
+
+ header_content = strdup(header+11);
+ if (header_content == NULL)
+ {
+ log_error(LOG_LEVEL_ERROR,
+ "Out of memory while looking for keep-alive keyword in %s", header);
+ return FALSE;
+ }
+
+ segments = ssplit(header_content, " ,", keywords, SZ(keywords));
+ while (segments-- > 0)
+ {
+ if (!strcmpic(keywords[segments], "keep-alive"))
+ {
+ keep_alive_keyword_present = TRUE;
+ break;
+ }
+ }
+
+ freez(header_content);
+
+ return keep_alive_keyword_present;
+
+}
+
+
/*********************************************************************
*
* Function : server_connection
@@ -1811,7 +1856,7 @@ static jb_err filter_header(struct client_state *csp, char **header)
*********************************************************************/
static jb_err server_connection(struct client_state *csp, char **header)
{
- if (!strcmpic(*header, "Connection: keep-alive")
+ if (connection_header_contains_keep_alive_keyword(*header)
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
&& !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Privoxy-commits
mailing list