Le 08/04/2021 à 20:59, Tim Duesterhus a écrit :
Willy,
Christopher,
something simple for a start. This one adds the http-request action and a
very simple normalizer to test whether it works. Turns out it does :-)
You can see the new `ist` helpers in action already. I'm pretty happy that
I was able to implement this completely with the new `ist` API.
Just small comments but otherwise, this one looks good.
[...]
+/* Parses the http-request normalize-uri action. It expects a single
<normalizer>
+ * argument, corresponding too a value in `enum act_normalize_uri`.
+ *
+ * It returns ACT_RET_PRS_OK on success, ACT_RET_PRS_ERR on error.
+ */
+static enum act_parse_ret parse_http_normalize_uri(const char **args, int
*orig_arg, struct proxy *px,
+ struct act_rule *rule, char
**err)
+{
+ int cur_arg = *orig_arg;
+
+ rule->action_ptr = http_action_normalize_uri;
+ rule->release_ptr = NULL;
+
+ if (!*args[cur_arg] ||
+ (*args[cur_arg + 1] && strcmp(args[cur_arg + 1], "if") != 0 &&
strcmp(args[cur_arg + 1], "unless") != 0)) {
Testing "if" or "unless" is useless here. If no normalizer name is provided,
this will be catch in the else statement. Especially because this test will be
removed by the 6th patch.
+ memprintf(err, "expects exactly 1 argument <normalizer>");
+ return ACT_RET_PRS_ERR;
+ }
+
+ if (strcmp(args[cur_arg], "merge-slashes") == 0) {
+ rule->action = ACT_NORMALIZE_URI_MERGE_SLASHES;
+ }
+ else {
+ memprintf(err, "unknown normalizer '%s'", args[cur_arg]);
+ return ACT_RET_PRS_ERR;
The list of supported normalizers may help the user here.
+ }
+ cur_arg++;
+
+ *orig_arg = cur_arg;
+ return ACT_RET_PRS_OK;
+}
+
--
Christopher Faulet