From: Willy Tarreau Date: Fri, 31 Jan 2014 14:45:34 +0000 (+0100) Subject: BUG/MEDIUM: http: fix regression caused by recent switch to keep-alive by default X-Git-Tag: v1.5-dev22~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=416ce618be9322d90d1c031bd5300ff280e28568;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: http: fix regression caused by recent switch to keep-alive by default Yesterday's commit 70dffda ("MAJOR: http: switch to keep-alive mode by default") broke HTTP/1.0 handling without keep-alive when keep-alive is enabled both in the frontend and in the backend. Before this patch, it used to work because tunnel mode was the default one, so if no mode was present in the frontend and a mode was set in the backend, the backend was the first one to parse the header. This is what the original patch tried to do with keep-alive by default, causing the version and the connection header to be ignored if both the frontend and the backend were running in keep-alive mode. The fix consists in always parsing the header in non-tunnel mode, and processing the rest of the logic in at least once, and again if the backend works in a different mode than the frontend. This is 1.5-specific, no backport is needed. --- diff --git a/src/proto_http.c b/src/proto_http.c index bd07984d07..e92dc6a6ab 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -3549,8 +3549,7 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit, * time. */ - if ((!(txn->flags & TX_HDR_CONN_PRS) && - ((s->fe->options & PR_O_HTTP_MODE) != PR_O_HTTP_KAL)) || + if (!(txn->flags & TX_HDR_CONN_PRS) || ((s->fe->options & PR_O_HTTP_MODE) != (s->be->options & PR_O_HTTP_MODE))) { int tmp = TX_CON_WANT_KAL; @@ -3581,7 +3580,8 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit, if ((txn->flags & TX_CON_WANT_MSK) < tmp) txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | tmp; - if (!(txn->flags & TX_HDR_CONN_PRS)) { + if (!(txn->flags & TX_HDR_CONN_PRS) && + (txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) { /* parse the Connection header and possibly clean it */ int to_del = 0; if ((msg->flags & HTTP_MSGF_VER_11) ||