]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: session: only call http_send_name_header() when changing the server
authorWilly Tarreau <w@1wt.eu>
Sun, 7 Apr 2013 16:19:16 +0000 (18:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2013 16:18:01 +0000 (18:18 +0200)
Till now we used to call the function until the connection established, which
means that the header rewriting was performed for nothing upon each even (eg:
uploaded contents) until the server responded or timed out.

Now we only call the function when we assign the server.

src/session.c

index 8556284366b0ea4c71f3ec7d496606d3f58588a9..d44583b1e6a7efbbd92dad57d0ecfc5ec053fdf7 100644 (file)
@@ -2194,21 +2194,22 @@ struct task *process_session(struct task *t)
                         */
                        if (s->si[1].state != SI_ST_REQ)
                                sess_update_stream_int(s, &s->si[1]);
-                       if (s->si[1].state == SI_ST_REQ)
+                       if (s->si[1].state == SI_ST_REQ) {
                                sess_prepare_conn_req(s, &s->si[1]);
 
+                               /* Now we can add the server name to a header (if requested) */
+                               /* check for HTTP mode and proxy server_name_hdr_name != NULL */
+                               if ((s->flags & SN_BE_ASSIGNED) &&
+                                   (s->be->mode == PR_MODE_HTTP) &&
+                                   (s->be->server_id_hdr_name != NULL)) {
+                                       http_send_name_header(&s->txn, s->be, objt_server(s->target)->id);
+                               }
+                       }
+
                        srv = objt_server(s->target);
                        if (s->si[1].state == SI_ST_ASS && srv && srv->rdr_len && (s->flags & SN_REDIRECTABLE))
                                http_perform_server_redirect(s, &s->si[1]);
                } while (s->si[1].state == SI_ST_ASS);
-
-               /* Now we can add the server name to a header (if requested) */
-               /* check for HTTP mode and proxy server_name_hdr_name != NULL */
-               if ((s->flags & SN_BE_ASSIGNED) &&
-                   (s->be->mode == PR_MODE_HTTP) &&
-                   (s->be->server_id_hdr_name != NULL)) {
-                       http_send_name_header(&s->txn, s->be, objt_server(s->target)->id);
-               }
        }
 
        /* Benchmarks have shown that it's optimal to do a full resync now */