mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
MINOR: http_ext: add rfc7239_is_valid converter
Adding new http converter: rfc7239_is_valid. Takes a string representing 7239 forwarded header single value as input and returns bool:TRUE if header is RFC compliant and bool:FALSE otherwise. Example: acl valid req.hdr(forwarded),rfc7239_is_valid #input: "for=127.0.0.1;proto=http" # output: TRUE #input: "proto=custom" # output: FALSE Depends on: - "MINOR: http_ext: introduce http ext converters"
This commit is contained in:
parent
82faad1069
commit
5c6f86f465
@ -17217,6 +17217,17 @@ The currently available list of transformation keywords include :
|
|||||||
http-request set-header X-51D-DeviceTypeMobileTablet \
|
http-request set-header X-51D-DeviceTypeMobileTablet \
|
||||||
%[req.fhdr(User-Agent),51d.single(DeviceType,IsMobile,IsTablet)]
|
%[req.fhdr(User-Agent),51d.single(DeviceType,IsMobile,IsTablet)]
|
||||||
|
|
||||||
|
rfc7239_is_valid
|
||||||
|
Returns true if input header is RFC 7239 compliant header value and false
|
||||||
|
otherwise.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
acl valid req.hdr(forwarded),rfc7239_is_valid
|
||||||
|
#input: "for=127.0.0.1;proto=http"
|
||||||
|
# output: TRUE
|
||||||
|
#input: "proto=custom"
|
||||||
|
# output: FALSE
|
||||||
|
|
||||||
add(<value>)
|
add(<value>)
|
||||||
Adds <value> to the input value of type signed integer, and returns the
|
Adds <value> to the input value of type signed integer, and returns the
|
||||||
result as a signed integer. <value> can be a numeric value or a variable
|
result as a signed integer. <value> can be a numeric value or a variable
|
||||||
|
@ -1370,8 +1370,22 @@ void http_ext_xot_copy(struct http_ext_xot *dest, const struct http_ext_xot *ori
|
|||||||
* related converters
|
* related converters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* input: string representing 7239 forwarded header single value
|
||||||
|
* does not take arguments
|
||||||
|
* output: 1 if header is RFC compliant, 0 otherwise
|
||||||
|
*/
|
||||||
|
static int sample_conv_7239_valid(const struct arg *args, struct sample *smp, void *private)
|
||||||
|
{
|
||||||
|
struct ist input = ist2(smp->data.u.str.area, smp->data.u.str.data);
|
||||||
|
|
||||||
|
smp->data.type = SMP_T_BOOL;
|
||||||
|
smp->data.u.sint = !!http_validate_7239_header(input, FORWARDED_HEADER_ALL, NULL);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Note: must not be declared <const> as its list will be overwritten */
|
/* Note: must not be declared <const> as its list will be overwritten */
|
||||||
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
|
||||||
|
{ "rfc7239_is_valid", sample_conv_7239_valid, 0, NULL, SMP_T_STR, SMP_T_BOOL},
|
||||||
{ NULL, NULL, 0, 0, 0 },
|
{ NULL, NULL, 0, 0, 0 },
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user