From: Thierry FOURNIER Date: Thu, 4 Jun 2015 09:44:06 +0000 (+0200) Subject: MINOR: tcp/http/conf: extends the keyword registration options X-Git-Tag: v1.6-dev2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e11863a6fa1a049c22d141d2c864a1b1a999ae5;p=thirdparty%2Fhaproxy.git MINOR: tcp/http/conf: extends the keyword registration options This patch permits to register a new keyword with the keyword "tcp-request content" 'tcp-request connection", tcp-response content", http-request" and "http-response" which is identified only by matching the start of the keyword. for example, we register the keyword "set-var" with the option "match_pfx" and the configuration keyword "set-var(var_name)" matchs this entry. --- diff --git a/include/types/proto_http.h b/include/types/proto_http.h index 0e51412a1e..fc8647593f 100644 --- a/include/types/proto_http.h +++ b/include/types/proto_http.h @@ -534,11 +534,13 @@ struct http_method_name { struct http_req_action_kw { const char *kw; int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct http_req_rule *rule, char **err); + int match_pfx; }; struct http_res_action_kw { const char *kw; int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct http_res_rule *rule, char **err); + int match_pfx; }; struct http_req_action_kw_list { diff --git a/include/types/proto_tcp.h b/include/types/proto_tcp.h index a6af2d37ef..d34ff035cb 100644 --- a/include/types/proto_tcp.h +++ b/include/types/proto_tcp.h @@ -65,6 +65,7 @@ struct tcp_action_kw { const char *kw; int (*parse)(const char **args, int *cur_arg, struct proxy *px, struct tcp_rule *rule, char **err); + int match_pfx; }; struct tcp_action_kw_list { diff --git a/src/proto_http.c b/src/proto_http.c index def5670bb2..5b06233c68 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -12809,6 +12809,9 @@ struct http_req_action_kw *action_http_req_custom(const char *kw) list_for_each_entry(kw_list, &http_req_keywords.list, list) { for (i = 0; kw_list->kw[i].kw != NULL; i++) { + if (kw_list->kw[i].match_pfx && + strncmp(kw, kw_list->kw[i].kw, strlen(kw_list->kw[i].kw)) == 0) + return &kw_list->kw[i]; if (!strcmp(kw, kw_list->kw[i].kw)) return &kw_list->kw[i]; } @@ -12828,6 +12831,9 @@ struct http_res_action_kw *action_http_res_custom(const char *kw) list_for_each_entry(kw_list, &http_res_keywords.list, list) { for (i = 0; kw_list->kw[i].kw != NULL; i++) { + if (kw_list->kw[i].match_pfx && + strncmp(kw, kw_list->kw[i].kw, strlen(kw_list->kw[i].kw)) == 0) + return &kw_list->kw[i]; if (!strcmp(kw, kw_list->kw[i].kw)) return &kw_list->kw[i]; } diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 4a4a806d15..036191b48d 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -145,6 +145,9 @@ static struct tcp_action_kw *tcp_req_conn_action(const char *kw) list_for_each_entry(kw_list, &tcp_req_conn_keywords, list) { for (i = 0; kw_list->kw[i].kw != NULL; i++) { + if (kw_list->kw[i].match_pfx && + strncmp(kw, kw_list->kw[i].kw, strlen(kw_list->kw[i].kw)) == 0) + return &kw_list->kw[i]; if (!strcmp(kw, kw_list->kw[i].kw)) return &kw_list->kw[i]; } @@ -162,6 +165,9 @@ static struct tcp_action_kw *tcp_req_cont_action(const char *kw) list_for_each_entry(kw_list, &tcp_req_cont_keywords, list) { for (i = 0; kw_list->kw[i].kw != NULL; i++) { + if (kw_list->kw[i].match_pfx && + strncmp(kw, kw_list->kw[i].kw, strlen(kw_list->kw[i].kw)) == 0) + return &kw_list->kw[i]; if (!strcmp(kw, kw_list->kw[i].kw)) return &kw_list->kw[i]; } @@ -179,6 +185,9 @@ static struct tcp_action_kw *tcp_res_cont_action(const char *kw) list_for_each_entry(kw_list, &tcp_res_cont_keywords, list) { for (i = 0; kw_list->kw[i].kw != NULL; i++) { + if (kw_list->kw[i].match_pfx && + strncmp(kw, kw_list->kw[i].kw, strlen(kw_list->kw[i].kw)) == 0) + return &kw_list->kw[i]; if (!strcmp(kw, kw_list->kw[i].kw)) return &kw_list->kw[i]; }