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.
This commit is contained in:
Willy Tarreau 2014-01-31 15:45:34 +01:00
parent 0b90f310dd
commit 416ce618be

View File

@ -3549,8 +3549,7 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit,
* time. * time.
*/ */
if ((!(txn->flags & TX_HDR_CONN_PRS) && if (!(txn->flags & TX_HDR_CONN_PRS) ||
((s->fe->options & PR_O_HTTP_MODE) != PR_O_HTTP_KAL)) ||
((s->fe->options & PR_O_HTTP_MODE) != (s->be->options & PR_O_HTTP_MODE))) { ((s->fe->options & PR_O_HTTP_MODE) != (s->be->options & PR_O_HTTP_MODE))) {
int tmp = TX_CON_WANT_KAL; 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) if ((txn->flags & TX_CON_WANT_MSK) < tmp)
txn->flags = (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 */ /* parse the Connection header and possibly clean it */
int to_del = 0; int to_del = 0;
if ((msg->flags & HTTP_MSGF_VER_11) || if ((msg->flags & HTTP_MSGF_VER_11) ||