On the backend side, when a CONNECT or an Extended CONNECT request was
sent, h2c_dec_hdrs() aborts the tunnel attempt as soon as a response
without H2_MSGF_BODY_TUNNEL is received. But h2_make_htx_response() clears
this flag for any status other than 2xx and 101, including interim
responses (1xx) such as 100 Continue or 103 Early Hints. H2_SF_BODY_TUNNEL
is then removed and H2_SF_TUNNEL_ABRT set, so that the final 200 response
is processed as a regular response with a body. The client receives the
interim and the final responses, but the connection is closed as soon as
data are exchanged. This breaks CONNECT and WebSocket (Extended CONNECT)
through H2 servers emitting interim responses.
Let's only abort the tunnel attempt on final responses.
This has been there since 2.4 with commit
d0db42326 ("MINOR: mux-h2: Add 2
flags to help to properly handle tunnel mode") and must be backported to
all stable versions.
if (msgf & H2_MSGF_BODY_TUNNEL)
*flags |= H2_SF_BODY_TUNNEL;
- else {
- /* Abort the tunnel attempt, if any */
+ else if (!(msgf & H2_MSGF_RSP_1XX)) {
+ /* Abort the tunnel attempt, if any, on a final response */
if (*flags & H2_SF_BODY_TUNNEL)
*flags |= H2_SF_TUNNEL_ABRT;
*flags &= ~H2_SF_BODY_TUNNEL;