mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-02-26 19:52:06 +01:00
[MEDIUM] make it possible to combine http-pretend-keepalived with httpclose
Some configs may involve httpclose in a frontend and http-pretend-keepalive in a backend. httpclose used to take priority over keepalive, thus voiding its effect. This change ensures that when both are combined, keepalive is still announced to the server while close is announced to the client. (cherry picked from commit 2be7ec90fa9caf66294f446423bbab2d00db9004)
This commit is contained in:
parent
e3f284aa7b
commit
22a9534213
@ -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.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user