]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tcp/http/conf: extends the keyword registration options
authorThierry FOURNIER <tfournier@arpalert.org>
Thu, 4 Jun 2015 09:44:06 +0000 (11:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 13 Jun 2015 21:01:37 +0000 (23:01 +0200)
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.

include/types/proto_http.h
include/types/proto_tcp.h
src/proto_http.c
src/proto_tcp.c

index 0e51412a1e57a118ca0105e92e58108cc8054791..fc8647593f6570079e03efee6e0e1c9b93173e2e 100644 (file)
@@ -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 {
index a6af2d37ef94a77558f06672b316808736a521d2..d34ff035cba9f235056d58f8388d1c26d13defbf 100644 (file)
@@ -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 {
index def5670bb238b601651991c1d0c5312a718d4181..5b06233c68335e6cbe2f8b7ab3328a150bbd8371 100644 (file)
@@ -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];
                        }
index 4a4a806d1598b9dc9ea038372767e74c6cdc2ae8..036191b48da97418e190d4804763a917f12a2a99 100644 (file)
@@ -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];
                }