]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] http: detect tunnel mode and set it in the session
authorWilly Tarreau <w@1wt.eu>
Mon, 30 Nov 2009 11:19:56 +0000 (12:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 30 Nov 2009 11:19:56 +0000 (12:19 +0100)
In order to support keepalive, we'll have to differentiate
normal sessions from tunnel sessions, which are the ones we
don't want to analyse further.

Those are typically the CONNECT requests where we don't care
about any form of content-length, as well as the requests
which are forwarded on non-close and non-keepalive proxies.

include/types/session.h
src/proto_http.c

index 6e2344f87bf2df4140d7b8f7e698c3e4718eecc9..64ba1866ce9aaaa482f4297bb3b7eb3f7f24b379 100644 (file)
@@ -52,7 +52,7 @@
 #define SN_REDISP      0x00000100      /* set if this session was redispatched from one server to another */
 #define SN_CONN_TAR    0x00000200      /* set if this session is turning around before reconnecting */
 #define SN_REDIRECTABLE        0x00000400      /* set if this session is redirectable (GET or HEAD) */
-/* unused:              0x00000800 */
+#define SN_TUNNEL      0x00000800      /* tunnel-mode session, nothing to catch after data */
 
 /* session termination conditions, bits values 0x1000 to 0x7000 (0-7 shift 12) */
 #define SN_ERR_NONE     0x00000000
index 10874c5fc8cbcad53379e88761a09cf561006843..e4662a3f386ce184e59bef1c8074f3d034307fea 100644 (file)
@@ -2611,6 +2611,15 @@ int http_process_request(struct session *s, struct buffer *req, int an_bit)
                }
        }
 
+
+       /* indicate in the session if it will be a tunnel-mode one or not. If
+        * we don't intend to analyse contents after the first request, it's a
+        * tunnel.
+        */
+       if (s->txn.meth == HTTP_METH_CONNECT ||
+           !((s->fe->options|s->be->options) & (PR_O_KEEPALIVE|PR_O_HTTP_CLOSE|PR_O_FORCE_CLO)))
+               s->flags |= SN_TUNNEL;
+
        /* 11: add "Connection: close" if needed and not yet set. */
        if (!(s->flags & SN_CONN_CLOSED) &&
            ((s->fe->options | s->be->options) & (PR_O_HTTP_CLOSE|PR_O_FORCE_CLO))) {