mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-14 07:24:32 +00:00
MAJOR: proxy/htx: Handle mux upgrades from TCP to HTTP in HTX mode
It is now possible to upgrade TCP streams to HTX when an HTTP backend is set for a TCP frontend (both with the HTX enabled). So concretely, in such case, an upgrade is performed from the mux pt to the mux h1. The current CS and the channel's buffer are used to initialize the mux h1.
This commit is contained in:
parent
eb7098035c
commit
bbe685452f
16
src/proxy.c
16
src/proxy.c
@ -1325,7 +1325,7 @@ int stream_set_backend(struct stream *s, struct proxy *be)
|
||||
proxy_inc_be_ctr(be);
|
||||
|
||||
/* HTX/legacy must match */
|
||||
if ((s->sess->fe->options2 ^ be->options2) & PR_O2_USE_HTX)
|
||||
if ((strm_fe(s)->options2 ^ be->options2) & PR_O2_USE_HTX)
|
||||
return 0;
|
||||
|
||||
/* assign new parameters to the stream from the new backend */
|
||||
@ -1371,6 +1371,20 @@ int stream_set_backend(struct stream *s, struct proxy *be)
|
||||
((strm_fe(s)->options & PR_O_HTTP_MODE) != (be->options & PR_O_HTTP_MODE)))
|
||||
http_adjust_conn_mode(s, s->txn, &s->txn->req);
|
||||
|
||||
/* If we chain a TCP frontend to an HTX backend, we must upgrade
|
||||
* the client mux */
|
||||
if (!IS_HTX_STRM(s) && be->mode == PR_MODE_HTTP && (be->options2 & PR_O2_USE_HTX)) {
|
||||
struct connection *conn = objt_conn(strm_sess(s)->origin);
|
||||
struct conn_stream *cs = objt_cs(s->si[0].end);
|
||||
|
||||
if (conn && cs) {
|
||||
si_rx_endp_more(&s->si[0]);
|
||||
if (conn_upgrade_mux_fe(conn, cs, &s->req.buf, ist(""), PROTO_MODE_HTX) == -1)
|
||||
return 0;
|
||||
s->flags |= SF_HTX;
|
||||
}
|
||||
}
|
||||
|
||||
/* If an LB algorithm needs to access some pre-parsed body contents,
|
||||
* we must not start to forward anything until the connection is
|
||||
* confirmed otherwise we'll lose the pointer to these data and
|
||||
|
Loading…
Reference in New Issue
Block a user