# through its log whether the trailer field name is present in what it
# relayed. This gives a positive assertion for both the dropped and the
# forwarded case.
+#
+# When the trailers are dropped on the H2 side, the end of the message must
+# still be reported (END_STREAM flag). Here vtest is able to parse the H2
+# trailers, so the H2 peers are checked directly. Chunked messages without
+# trailers are also tested because they end with an EOT block too.
feature ignore_unknown_macro
} -start
# the origin of the response side, which emits the trailers
-server s2 -repeat 2 {
+server s2 -repeat 3 {
rxreq
txresp -nolen -hdr "transfer-encoding: chunked"
send "5\r\nworld\r\n0\r\nx-rtlr1: rvalue1\r\n\r\n"
} -start
+# the origin of the response side, emitting a chunked message without
+# trailers
+server s3 {
+ rxreq
+ txresp -nolen -hdr "transfer-encoding: chunked"
+ send "5\r\nworld\r\n0\r\n\r\n"
+} -start
+
+# H2 origin of the request side. The whole request, up to the END_STREAM
+# flag, must be received.
+server s4 {
+ rxpri
+ stream 0 {
+ txsettings
+ rxsettings
+ txsettings -ack
+ } -run
+
+ stream 1 {
+ rxreq
+ expect req.url == "/drop"
+ expect req.bodylen == 5
+ expect req.http.x-tlr1 == "<undef>"
+ txresp
+ } -run
+
+ stream 3 {
+ rxreq
+ expect req.url == "/no-trailers"
+ expect req.bodylen == 5
+ txresp
+ } -run
+} -start
+
# request side observer, between the proxy and the origin
haproxy hreq -conf {
global
backend be_res
server s2 ${s2_addr}:${s2_port}
+
+ # H2 on the server side, the request trailers are dropped
+ frontend fe_req_h2
+ bind "fd@${fereqh2}"
+ default_backend be_req_h2_drop
+
+ backend be_req_h2_drop
+ option http-drop-request-trailers
+ server s4 ${s4_addr}:${s4_port} proto h2
+
+ # H2 on the client side, the response trailers are dropped
+ frontend fe_res_h2_drop
+ bind "fd@${fereshdrop}" proto h2
+ option http-drop-response-trailers
+ use_backend be_res_no_tlr if { path /no-trailers }
+ default_backend be_res
+
+ backend be_res_no_tlr
+ server s3 ${s3_addr}:${s3_port}
} -start
# response side observer, between the client and the proxy
recv 33
} -run
+# the request trailers are dropped on their way to the H2 origin, but the
+# end of the message is still reported
+client c5 -connect ${h1_fereqh2_sock} {
+ txreq -req POST -url "/drop" -hdr "transfer-encoding: chunked" -nolen
+ send "5\r\nhello\r\n0\r\nx-tlr1: value1\r\n\r\n"
+ rxresp
+ expect resp.status == 200
+
+ txreq -req POST -url "/no-trailers" -hdr "transfer-encoding: chunked" -nolen
+ send "5\r\nhello\r\n0\r\n\r\n"
+ rxresp
+ expect resp.status == 200
+} -run
+
+# the response trailers are dropped on their way to the H2 client, but the
+# end of the message is still reported
+client c6 -connect ${h1_fereshdrop_sock} {
+ txpri
+ stream 0 {
+ txsettings
+ rxsettings
+ txsettings -ack
+ rxsettings
+ expect settings.ack == true
+ } -run
+
+ stream 1 {
+ txreq -url "/res"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 5
+ expect resp.http.x-rtlr1 == "<undef>"
+ } -run
+
+ stream 3 {
+ txreq -url "/no-trailers"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 5
+ } -run
+} -run
+
syslog Sreq -wait
syslog Sres -wait
int hdr;
int idx;
int eom = 0;
+ int drop;
TRACE_ENTER(H2_EV_TX_FRAME|H2_EV_TX_HDR, h2c->conn, h2s);
/* get trailers. */
hdr = 0;
- /* Skip the trailers because the corresponding conf option was set */
- if ((!(h2c->flags & H2_CF_IS_BACK) && (h2c->proxy->options & PR_O_HTTP_DROP_RES_TRLS)) ||
- ((h2c->flags & H2_CF_IS_BACK) && (h2c->proxy->options & PR_O_HTTP_DROP_REQ_TRLS)))
- goto skip_trailers;
+ /* Skip the trailers if the corresponding conf option was set. But the
+ * blocks must still be parsed to find the EOT and to know if the
+ * message is finished, to emit the ES flag.
+ */
+ drop = ((!(h2c->flags & H2_CF_IS_BACK) && (h2c->proxy->options & PR_O_HTTP_DROP_RES_TRLS)) ||
+ ((h2c->flags & H2_CF_IS_BACK) && (h2c->proxy->options & PR_O_HTTP_DROP_REQ_TRLS)));
for (blk = htx_get_head_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) {
type = htx_get_blk_type(blk);
break;
}
if (type == HTX_BLK_TLR) {
+ if (drop)
+ continue;
if (unlikely(hdr >= sizeof(list)/sizeof(list[0]) - 1)) {
TRACE_ERROR("too many headers", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s);
goto fail;
}
}
- skip_trailers:
/* marker for end of trailers */
list[hdr].n = ist("");