return 1;
}
+/* This function is used to validate the argument passed to the
+ * "capture.req.hdr" and "capture.res.hdr" fetch keywords. The capture
+ * identifier is used as an index in the stream's captures array, so it must not
+ * be negative. It is assumed that the type is already the correct one. Returns
+ * 0 on error, non-zero if OK. If <err_msg> is not NULL, it will be filled with a
+ * pointer to an error message in case of error, that the caller is responsible
+ * for freeing. The initial location must either be freeable or NULL.
+ */
+static int val_cap_id(struct arg *arg, char **err_msg)
+{
+ if (arg && arg[0].type == ARGT_SINT && arg[0].data.sint < 0) {
+ memprintf(err_msg, "capture identifier must be >= 0");
+ return 0;
+ }
+ return 1;
+}
+
int val_query(struct arg *args, char **err_msg)
{
int val = 0;
{ "baseq", smp_fetch_base, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
/* capture are allocated and are permanent in the stream */
- { "capture.req.hdr", smp_fetch_capture_req_hdr, ARG1(1,SINT), NULL, SMP_T_STR, SMP_USE_HRQHP },
+ { "capture.req.hdr", smp_fetch_capture_req_hdr, ARG1(1,SINT), val_cap_id, SMP_T_STR, SMP_USE_HRQHP },
/* retrieve these captures from the HTTP logs */
{ "capture.req.method", smp_fetch_capture_req_method, 0, NULL, SMP_T_STR, SMP_USE_HRQHP },
{ "capture.req.uri", smp_fetch_capture_req_uri, 0, NULL, SMP_T_STR, SMP_USE_HRQHP },
{ "capture.req.ver", smp_fetch_capture_req_ver, 0, NULL, SMP_T_STR, SMP_USE_HRQHP },
- { "capture.res.hdr", smp_fetch_capture_res_hdr, ARG1(1,SINT), NULL, SMP_T_STR, SMP_USE_HRSHP },
+ { "capture.res.hdr", smp_fetch_capture_res_hdr, ARG1(1,SINT), val_cap_id, SMP_T_STR, SMP_USE_HRSHP },
{ "capture.res.ver", smp_fetch_capture_res_ver, 0, NULL, SMP_T_STR, SMP_USE_HRQHP },
/* cookie is valid in both directions (eg: for "stick ...") but cook*