# - reached from a frontend which has no capture at all;
# - reached from a frontend which has its own capture, which must be
# left untouched.
+# They are run for an "http-request capture" and for a "tcp-request content
+# capture" rule.
feature ignore_unknown_macro
bind "fd@${lst}"
http-request capture req.hdr(x-b) len 40
http-request return status 200 hdr cap0 "%[capture.req.hdr(0)]"
+
+ frontend fe_tcp_nocap
+ bind "fd@${fe_tcp_nocap}"
+ use_backend lst_tcp
+
+ frontend fe_tcp_cap
+ bind "fd@${fe_tcp_cap}"
+ capture request header x-a len 1
+ use_backend lst_tcp
+
+ listen lst_tcp
+ bind "fd@${lst_tcp}"
+ tcp-request inspect-delay 1s
+ tcp-request content capture req.hdr(x-b) len 40
+ http-request return status 200 hdr cap0 "%[capture.req.hdr(0)]"
} -start
client c1 -connect ${h1_lst_sock} {
expect resp.status == 200
expect resp.http.cap0 == "A"
} -run
+
+client c4 -connect ${h1_lst_tcp_sock} {
+ txreq -hdr "x-b: hello"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.cap0 == "hello"
+} -run
+
+client c5 -connect ${h1_fe_tcp_nocap_sock} {
+ txreq -hdr "x-b: hello"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.cap0 == "<undef>"
+} -run
+
+client c6 -connect ${h1_fe_tcp_cap_sock} {
+ txreq -hdr "x-a: A" -hdr "x-b: hello"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.cap0 == "A"
+} -run
char **cap = s->req_cap;
int len, opt;
+ /* The capture slot was declared in the proxy holding the rule, but the
+ * slots of the stream are those of its frontend. When the rule is
+ * evaluated from a listen section used as a backend, the slot does not
+ * exist, so the rule is ignored.
+ */
+ if (px != strm_fe(s))
+ goto end;
+
opt = ((rule->from == ACT_F_TCP_REQ_CNT) ? SMP_OPT_DIR_REQ : SMP_OPT_DIR_RES);
if (flags & ACT_FLAG_FINAL)
opt |= SMP_OPT_FINAL;