]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h2: skip the response trailers if any
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 16:15:59 +0000 (17:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:16:19 +0000 (18:16 +0100)
For now we don't build a HEADERS frame with them, but at least we remove
them from the response so that the L7 chunk parser inside isn't blocked
on these (often two) remaining bytes that don't want to leave the buffer.
It also ensures that trailers delivered progressively will correctly be
skipped.

src/mux_h2.c

index 7b9c0bc5cf7ae63761f60e2527d931476f5ebc81..e0e2ebe57b422299f2c4c1ca7a980259cd3b1e07 100644 (file)
@@ -2300,9 +2300,10 @@ static int h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf)
                        h2s->st = H2_SS_HLOC;
                else
                        h2s->st = H2_SS_CLOSED;
-               /* no trailers for now, we must consume them (whatever remains in the buffer) */
-               bo_del(buf, buf->o);
-               h1m->state = HTTP_MSG_DONE;
+
+               if (!(h1m->flags & H1_MF_CHNK))
+                       h1m->state = HTTP_MSG_DONE;
+
                h2s->flags |= H2_SF_ES_SENT;
        }
 
@@ -2337,6 +2338,20 @@ static int h2_snd_buf(struct conn_stream *cs, struct buffer *buf, int flags)
                        if (h2s->flags & H2_SF_BLK_ANY)
                                break;
                }
+               else if (h2s->res.state == HTTP_MSG_TRAILERS) {
+                       /* consume the trailers if any (we don't forward them for now) */
+                       int count = h1_measure_trailers(buf);
+
+                       if (unlikely(count <= 0)) {
+                               if (count < 0)
+                                       h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
+                               break;
+                       }
+                       total += count;
+                       bo_del(buf, count);
+                       h2s->res.state = HTTP_MSG_DONE;
+                       break;
+               }
                else {
                        cs->flags |= CS_FL_ERROR;
                        break;