MINOR: uri_normalizer: Add a `sort-query` normalizer
This normalizer sorts the `&` delimited query parameters by parameter name.
See GitHub Issue #714.
diff --git a/src/http_act.c b/src/http_act.c
index 3751b00..1480563 100644
--- a/src/http_act.c
+++ b/src/http_act.c
@@ -250,6 +250,23 @@
break;
}
+ case ACT_NORMALIZE_URI_SORT_QUERY: {
+ const struct ist path = http_get_path(uri);
+ struct ist newquery = ist2(replace->area, replace->size);
+
+ if (!isttest(path))
+ goto leave;
+
+ err = uri_normalizer_query_sort(istfind(path, '?'), '&', &newquery);
+
+ if (err != URI_NORMALIZER_ERR_NONE)
+ break;
+
+ if (!http_replace_req_query(htx, newquery))
+ goto fail_rewrite;
+
+ break;
+ }
}
switch (err) {
@@ -330,6 +347,11 @@
return ACT_RET_PRS_ERR;
}
}
+ else if (strcmp(args[cur_arg], "sort-query") == 0) {
+ cur_arg++;
+
+ rule->action = ACT_NORMALIZE_URI_SORT_QUERY;
+ }
else {
memprintf(err, "unknown normalizer '%s'", args[cur_arg]);
return ACT_RET_PRS_ERR;