BUG/MEDIUM: htx: Fix the process of HTTP CONNECT with h2 connections
In HTX, the HTTP tunneling does not work if h1 and h2 are mixed (an h1 client
sending requests to an h2 server or this opposite) because the h1 multiplexer
always adds an EOM before switching it to tunnel mode. The h2 multiplexer
interprets it as an end of stream, closing the stream as for any other
transaction.
To make it works again, we need to swith to the tunnel mode without emitting any
EOM blocks. Because of that, HTX analyzers have been updated to switch the
transaction to tunnel mode before end of the message (because there is no end of
message...).
To be consistent, the protocol switching is also handled the same way even
though the 101 responses are not supported in h2.
This patch must be backported to 1.9.
diff --git a/src/proto_htx.c b/src/proto_htx.c
index 3387943..3837666 100644
--- a/src/proto_htx.c
+++ b/src/proto_htx.c
@@ -1236,6 +1236,11 @@
channel_htx_forward_forever(req, htx);
}
+ if (txn->meth == HTTP_METH_CONNECT) {
+ msg->msg_state = HTTP_MSG_TUNNEL;
+ goto done;
+ }
+
/* Check if the end-of-message is reached and if so, switch the message
* in HTTP_MSG_DONE state.
*/
@@ -2159,12 +2164,10 @@
channel_htx_forward_forever(res, htx);
}
- if (!(msg->flags & HTTP_MSGF_XFER_LEN)) {
- /* The server still sending data that should be filtered */
- if (res->flags & CF_SHUTR || !HAS_RSP_DATA_FILTERS(s)) {
- msg->msg_state = HTTP_MSG_TUNNEL;
- goto done;
- }
+ if ((txn->meth == HTTP_METH_CONNECT && txn->status == 200) || txn->status == 101 ||
+ (!(msg->flags & HTTP_MSGF_XFER_LEN) && (res->flags & CF_SHUTR || !HAS_RSP_DATA_FILTERS(s)))) {
+ msg->msg_state = HTTP_MSG_TUNNEL;
+ goto done;
}
/* Check if the end-of-message is reached and if so, switch the message