]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: disable header captures in TCP mode and complain
authorWilly Tarreau <w@1wt.eu>
Sat, 24 Mar 2012 07:33:05 +0000 (08:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 24 Mar 2012 07:35:37 +0000 (08:35 +0100)
In order to help users fix their configs, report a warning when a capture
has been set on a non-HTTP frontend.

This should be backported to 1.4.

src/cfgparse.c

index 6f1df9c997c5b48ce2acffa967653884a8e68603..5996e26728e8d1b0f3ba8085813a8dcd9f5cc24b 100644 (file)
@@ -6062,14 +6062,33 @@ out_uri_auth_compat:
                }
 
                /* The small pools required for the capture lists */
-               if (curproxy->nb_req_cap)
-                       curproxy->req_cap_pool = create_pool("ptrcap",
-                                                            curproxy->nb_req_cap * sizeof(char *),
-                                                            MEM_F_SHARED);
-               if (curproxy->nb_rsp_cap)
-                       curproxy->rsp_cap_pool = create_pool("ptrcap",
-                                                            curproxy->nb_rsp_cap * sizeof(char *),
-                                                            MEM_F_SHARED);
+               if (curproxy->nb_req_cap) {
+                       if (curproxy->mode == PR_MODE_HTTP) {
+                               curproxy->req_cap_pool = create_pool("ptrcap",
+                                                                    curproxy->nb_req_cap * sizeof(char *),
+                                                                    MEM_F_SHARED);
+                       } else {
+                               Warning("config : 'capture request header' ignored for %s '%s' as it requires HTTP mode.\n",
+                                       proxy_type_str(curproxy), curproxy->id);
+                               err_code |= ERR_WARN;
+                               curproxy->to_log &= ~LW_REQHDR;
+                               curproxy->nb_req_cap = 0;
+                       }
+               }
+
+               if (curproxy->nb_rsp_cap) {
+                       if (curproxy->mode == PR_MODE_HTTP) {
+                               curproxy->rsp_cap_pool = create_pool("ptrcap",
+                                                                    curproxy->nb_rsp_cap * sizeof(char *),
+                                                                    MEM_F_SHARED);
+                       } else {
+                               Warning("config : 'capture response header' ignored for %s '%s' as it requires HTTP mode.\n",
+                                       proxy_type_str(curproxy), curproxy->id);
+                               err_code |= ERR_WARN;
+                               curproxy->to_log &= ~LW_REQHDR;
+                               curproxy->nb_rsp_cap = 0;
+                       }
+               }
 
                /* first, we will invert the servers list order */
                newsrv = NULL;