struct sample *sample_process(struct proxy *px, struct session *sess,
struct stream *strm, unsigned int opt,
struct sample_expr *expr, struct sample *p);
-struct sample *sample_fetch_string(struct proxy *px, struct session *sess,
+struct sample *sample_fetch_as_type(struct proxy *px, struct session *sess,
struct stream *strm, unsigned int opt,
- struct sample_expr *expr);
+ struct sample_expr *expr, int smp_type);
void sample_register_fetches(struct sample_fetch_kw_list *psl);
void sample_register_convs(struct sample_conv_kw_list *psl);
const char *sample_src_names(unsigned int use);
case LOG_FMT_EXPR: // sample expression, may be request or response
key = NULL;
if (tmp->options & LOG_OPT_REQ_CAP)
- key = sample_fetch_string(be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, tmp->expr);
+ key = sample_fetch_as_type(be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, tmp->expr, SMP_T_STR);
if (!key && (tmp->options & LOG_OPT_RES_CAP))
- key = sample_fetch_string(be, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL, tmp->expr);
+ key = sample_fetch_as_type(be, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL, tmp->expr, SMP_T_STR);
if (tmp->options & LOG_OPT_HTTP)
ret = encode_chunk(tmplog, dst + maxsize,
'%', http_encode_map, key ? &key->data.str : &empty);
char **cap = s->req_cap;
int len;
- key = sample_fetch_string(s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, expr);
+ key = sample_fetch_as_type(s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, expr, SMP_T_STR);
if (!key)
return 1;
if (!h)
return 1;
- key = sample_fetch_string(s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, expr);
+ key = sample_fetch_as_type(s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, expr, SMP_T_STR);
if (!key)
return 1;
if (!h)
return 1;
- key = sample_fetch_string(s->be, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL, expr);
+ key = sample_fetch_as_type(s->be, sess, s, SMP_OPT_DIR_RES|SMP_OPT_FINAL, expr, SMP_T_STR);
if (!key)
return 1;
char **cap = s->req_cap;
int len;
- key = sample_fetch_string(s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->act_prm.cap.expr);
+ key = sample_fetch_as_type(s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->act_prm.cap.expr, SMP_T_STR);
if (!key)
continue;
/*
* Process a fetch + format conversion as defined by the sample expression
* <expr> on request or response considering the <opt> parameter. The output is
- * always of type string. If a stable sample can be fetched, or an unstable one
- * when <opt> contains SMP_OPT_FINAL, the sample is converted to a string and
+ * not explicitly set to <smp_type>, but shall be compatible with it as
+ * specified by 'sample_casts' table. If a stable sample can be fetched, or an
+ * unstable one when <opt> contains SMP_OPT_FINAL, the sample is converted and
* returned without the SMP_F_MAY_CHANGE flag. If an unstable sample is found
* and <opt> does not contain SMP_OPT_FINAL, then the sample is returned as-is
* with its SMP_F_MAY_CHANGE flag so that the caller can check it and decide to
* smp 1 0 Not present yet, may appear later (eg: header)
* smp 1 1 never happens (either flag is cleared on output)
*/
-struct sample *sample_fetch_string(struct proxy *px, struct session *sess,
+struct sample *sample_fetch_as_type(struct proxy *px, struct session *sess,
struct stream *strm, unsigned int opt,
- struct sample_expr *expr)
+ struct sample_expr *expr, int smp_type)
{
struct sample *smp = &temp_smp;
return NULL;
}
- if (!sample_casts[smp->type][SMP_T_STR])
+ if (!sample_casts[smp->type][smp_type])
return NULL;
- if (!sample_casts[smp->type][SMP_T_STR](smp))
+ if (!sample_casts[smp->type][smp_type](smp))
return NULL;
- smp->type = SMP_T_STR;
smp->flags &= ~SMP_F_MAY_CHANGE;
return smp;
}