]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] make it possible to combine http-pretend-keepalived with httpclose
authorWilly Tarreau <w@1wt.eu>
Wed, 29 Sep 2010 12:31:41 +0000 (14:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 30 Oct 2010 17:04:31 +0000 (19:04 +0200)
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)

doc/configuration.txt
src/proto_http.c

index e8455464af5438ae4228b34e6d71f78f5523661d..926ce9a216674baed850b6663f855abf14bdecb6 100644 (file)
@@ -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.
index 9d30ffc7f456a314fae37c8c0e3941b470df3a00..4e4ac4db1f78825204ab68f325cb7cd195762ff9 100644 (file)
@@ -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;
                }