]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] http request: update the TX_SRV_CONN_KA flag on rewrite
authorWilly Tarreau <w@1wt.eu>
Sun, 18 Oct 2009 19:04:35 +0000 (21:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 18 Oct 2009 19:10:21 +0000 (21:10 +0200)
If we modify the "connection" header we send to the server,
update the TX_SRV_CONN_KA flag.

src/proto_http.c

index 1212968a39eb67122d6dfccc11f40e1fc0366af8..5fd52117d547be54c7d61b003651b35c518cf183 100644 (file)
@@ -2203,7 +2203,10 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
                }
        }
 
-       /* We might have to check for "Connection:" */
+       /* We might have to check for "Connection:". The test for persistent
+        * connections has already been performed, so we only enter here if
+        * we are certain the connection is persistent.
+        */
        if (((s->fe->options | s->be->options) & (PR_O_HTTP_CLOSE|PR_O_FORCE_CLO)) &&
            !(s->flags & SN_CONN_CLOSED)) {
                char *cur_ptr, *cur_end, *cur_next;
@@ -2247,16 +2250,20 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
                                                txn->req.eoh += delta;
                                        }
                                        s->flags |= SN_CONN_CLOSED;
+                                       txn->flags &= ~TX_SRV_CONN_KA; /* keep-alive closed on server side */
                                }
                        }
                        old_idx = cur_idx;
                }
 
-               /* if there was no Connection header and we're in HTTP/1.0, then "close" is implied */
+               /* if there is no "Connection: keep-alive" header left and we're
+                * in HTTP/1.0, then non-persistent connection is implied */
                if (!(s->flags & SN_CONN_CLOSED) && (msg->sl.rq.v_l == 8) &&
                    (req->data[msg->som + msg->sl.rq.v + 5] == '1') &&
-                   (req->data[msg->som + msg->sl.rq.v + 7] == '0'))
+                   (req->data[msg->som + msg->sl.rq.v + 7] == '0')) {
                        s->flags |= SN_CONN_CLOSED;
+                       txn->flags &= ~TX_SRV_CONN_KA; /* keep-alive closed on server side */
+               }
        }
        /* add request headers from the rule sets in the same order */
        for (cur_idx = 0; cur_idx < px->nb_reqadd; cur_idx++) {