]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1/mux-fcgi: Don't set TUNNEL mode if payload length is unknown
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 8 Dec 2020 09:38:22 +0000 (10:38 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Jan 2021 15:37:14 +0000 (16:37 +0100)
Responses with no C-L and T-E headers are no longer switched in TUNNEL mode
and remains in DATA mode instead. The H1 and FCGI muxes are updated
accordingly. This change reflects the real message state. It is not a true
tunnel. Data received are still part of the message.

It is not a bug. However, this message may be backported after some
observation period (at least as far as 2.2).

src/h1_htx.c
src/mux_fcgi.c
src/mux_h1.c

index dc6accabbddddca6a6cd89023c31df05639c7a38..5ef995f7dc65d152ee08a254ec1ecea427bcc874 100644 (file)
@@ -296,10 +296,6 @@ static int h1_postparse_res_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx
                /* Responses with a known body length. */
                h1m->flags |= H1_MF_XFER_LEN;
        }
-       else {
-               /* Responses with an unknown body length */
-               h1m->state = H1_MSG_TUNNEL;
-       }
 
        used = htx_used_space(htx);
        flags = h1m_htx_sl_flags(h1m);
index 765cff3b8800190a5804b1ce3e6f23cbb7c2a928..65e511b650c5ef1a287672dc2e6807ea3a3df9c8 100644 (file)
@@ -3374,6 +3374,16 @@ static size_t fcgi_strm_parse_response(struct fcgi_strm *fstrm, struct buffer *b
                else if (h1m->state < H1_MSG_TRAILERS) {
                        TRACE_PROTO("parsing response payload", FCGI_EV_RSP_DATA|FCGI_EV_RSP_BODY, fconn->conn, fstrm);
                        ret = fcgi_strm_parse_data(fstrm, h1m, &htx, &fstrm->rxbuf, &total, count, buf);
+
+                       if (!(h1m->flags & H1_MF_XFER_LEN) && fstrm->state != FCGI_SS_ERROR &&
+                           (fstrm->flags & FCGI_SF_ES_RCVD) && b_data(&fstrm->rxbuf) == total) {
+                               TRACE_DEVEL("end of data", FCGI_EV_RSP_DATA, fconn->conn, fstrm);
+                               if (!(h1m->flags & H1_MF_VER_11))
+                                       fstrm->flags |= FCGI_SF_H1_PARSING_DONE;
+                               h1m->state = H1_MSG_DONE;
+                               TRACE_USER("H1 response fully rcvd", FCGI_EV_RSP_DATA|FCGI_EV_RSP_EOM, fconn->conn, fstrm, htx);
+                       }
+
                        if (!ret && h1m->state != H1_MSG_DONE)
                                break;
 
@@ -3402,23 +3412,6 @@ static size_t fcgi_strm_parse_response(struct fcgi_strm *fstrm, struct buffer *b
                        }
                        break;
                }
-               else if (h1m->state == H1_MSG_TUNNEL) {
-                       TRACE_PROTO("parsing response tunneled data", FCGI_EV_RSP_DATA, fconn->conn, fstrm);
-                       ret = fcgi_strm_parse_data(fstrm, h1m, &htx, &fstrm->rxbuf, &total, count, buf);
-
-                       if (fstrm->state != FCGI_SS_ERROR &&
-                           (fstrm->flags & FCGI_SF_ES_RCVD) && b_data(&fstrm->rxbuf) == total) {
-                               TRACE_DEVEL("end of tunneled data", FCGI_EV_RSP_DATA, fconn->conn, fstrm);
-                               if ((h1m->flags & (H1_MF_VER_11|H1_MF_XFER_LEN)) != H1_MF_VER_11)
-                                       fstrm->flags |= FCGI_SF_H1_PARSING_DONE;
-                               h1m->state = H1_MSG_DONE;
-                               TRACE_USER("H1 response fully rcvd", FCGI_EV_RSP_DATA|FCGI_EV_RSP_EOM, fconn->conn, fstrm, htx);
-                       }
-                       if (!ret && h1m->state != H1_MSG_DONE)
-                               break;
-
-                       TRACE_PROTO("rcvd H1 response tunneled data", FCGI_EV_RSP_DATA, fconn->conn, fstrm, htx);
-               }
                else {
                        htx->flags |= HTX_FL_PROCESSING_ERROR;
                        TRACE_PROTO("processing error", FCGI_EV_RSP_DATA, fconn->conn, fstrm);
index 19f8240f4ff1af352466f85787db6a11796be74b..00bb6dc51d61282656da23c9bda22d01027fec98 100644 (file)
@@ -1651,8 +1651,9 @@ static size_t h1_process_input(struct h1c *h1c, struct buffer *buf, size_t count
                h1s->cs->flags &= ~(CS_FL_RCV_MORE | CS_FL_WANT_ROOM);
                if (h1s->flags & H1S_F_REOS) {
                        h1s->cs->flags |= CS_FL_EOS;
-                       if (h1m->state >= H1_MSG_DONE) {
-                               /* DONE or TUNNEL, set EOI on the conn-stream */
+                       if (h1m->state >= H1_MSG_DONE || !(h1m->flags & H1_MF_XFER_LEN)) {
+                               /* DONE or TUNNEL or SHUTR without XFER_LEN, set
+                                * EOI on the conn-stream */
                                h1s->cs->flags |= CS_FL_EOI;
                        }
                        else if (h1m->state > H1_MSG_LAST_LF && h1m->state < H1_MSG_DONE)