mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-11 09:37:20 +02:00
[MINOR] acl: add the http_req_first match
This match returns true when the request calling it is the first one of a connection. (cherry picked from commit 922ca979c50653c415852531f36fe409190ad76b)
This commit is contained in:
parent
8aa6b3762c
commit
7f18e52b13
@ -7202,6 +7202,12 @@ http_auth_group(userlist) <group> [<group>]*
|
|||||||
|
|
||||||
Currently only http basic auth is supported.
|
Currently only http basic auth is supported.
|
||||||
|
|
||||||
|
http_req_first
|
||||||
|
Returns true when the request being processed is the first one of the
|
||||||
|
connection. This can be used to add or remove headers that may be missing
|
||||||
|
from some requests when a request is not the first one, or even to perform
|
||||||
|
some specific ACL checks only on the first request.
|
||||||
|
|
||||||
method <string>
|
method <string>
|
||||||
Applies to the method in the HTTP request, eg: "GET". Some predefined ACL
|
Applies to the method in the HTTP request, eg: "GET". Some predefined ACL
|
||||||
already check for most common methods.
|
already check for most common methods.
|
||||||
|
@ -7968,6 +7968,22 @@ acl_fetch_proto_http(struct proxy *px, struct session *s, void *l7, int dir,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return a valid test if the current request is the first one on the connection */
|
||||||
|
static int
|
||||||
|
acl_fetch_http_first_req(struct proxy *px, struct session *s, void *l7, int dir,
|
||||||
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
|
{
|
||||||
|
if (!s)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (s->txn.flags & TX_NOT_FIRST)
|
||||||
|
test->flags |= ACL_TEST_F_SET_RES_FAIL;
|
||||||
|
else
|
||||||
|
test->flags |= ACL_TEST_F_SET_RES_PASS;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
acl_fetch_http_auth(struct proxy *px, struct session *s, void *l7, int dir,
|
acl_fetch_http_auth(struct proxy *px, struct session *s, void *l7, int dir,
|
||||||
struct acl_expr *expr, struct acl_test *test)
|
struct acl_expr *expr, struct acl_test *test)
|
||||||
@ -8061,8 +8077,9 @@ static struct acl_kw_list acl_kws = {{ },{
|
|||||||
{ "cook_pst", acl_parse_none, acl_fetch_cook, acl_match_pst },
|
{ "cook_pst", acl_parse_none, acl_fetch_cook, acl_match_pst },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ "http_auth", acl_parse_nothing, acl_fetch_http_auth, acl_match_auth },
|
{ "http_auth", acl_parse_nothing, acl_fetch_http_auth, acl_match_auth, ACL_USE_L7REQ_PERMANENT },
|
||||||
{ "http_auth_group", acl_parse_strcat, acl_fetch_http_auth, acl_match_auth },
|
{ "http_auth_group", acl_parse_strcat, acl_fetch_http_auth, acl_match_auth, ACL_USE_L7REQ_PERMANENT },
|
||||||
|
{ "http_first_req", acl_parse_nothing, acl_fetch_http_first_req, acl_match_nothing, ACL_USE_L7REQ_PERMANENT },
|
||||||
{ NULL, NULL, NULL, NULL },
|
{ NULL, NULL, NULL, NULL },
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user