diff --git a/doc/configuration.txt b/doc/configuration.txt index e8455464a..926ce9a21 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -2834,8 +2834,9 @@ no option http-pretend-keepalive This option may be set both in a frontend and in a backend. It is enabled if at least one of the frontend or backend holding a connection has it enabled. - This option has no effect if it is combined with "option httpclose", which - has precedence. + This option may be compbined with "option httpclose", which will cause + keepalive to be announced to the server and close to be announced to the + client. This practice is discouraged though. If this option has been enabled in a "defaults" section, it can be disabled in a specific instance by prepending the "no" keyword before it. diff --git a/src/proto_http.c b/src/proto_http.c index 9d30ffc7f..4e4ac4db1 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -3006,7 +3006,8 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) && ((txn->flags & TX_HDR_CONN_CLO) || /* "connection: close" */ (txn->flags & (TX_REQ_VER_11|TX_HDR_CONN_KAL)) == 0 || /* no "connection: k-a" in 1.0 */ - ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE) || /* httpclose + any = forceclose */ + (((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE) && /* httpclose without pretend-ka... */ + 1/*!((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)*/) || /* ... +any = forceclose */ !(txn->flags & TX_REQ_XFER_LEN) || /* no length known => close */ s->fe->state == PR_STSTOPPED)) /* frontend is stopping */ txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO; @@ -3433,18 +3434,19 @@ int http_process_request(struct session *s, struct buffer *req, int an_bit) /* 11: add "Connection: close" or "Connection: keep-alive" if needed and not yet set. */ if (((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) || - ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE)) { + ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE) || + ((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) { unsigned int want_flags = 0; if (txn->flags & TX_REQ_VER_11) { - if (((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL && - !((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) || - ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE)) + if (((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL || + ((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE)) && + !((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) want_flags |= TX_CON_CLO_SET; } else { - if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL || - (((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA) && - !((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE))) + if (((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL && + !((s->fe->options|s->be->options) & PR_O_HTTP_CLOSE)) || + ((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) want_flags |= TX_CON_KAL_SET; }