BUG/MEDIUM: doc: Fix replace-path action description

The description of the replace-path action does not reflect what the code
do. When the request path is replaced, the query-string is preserved. But the
documentation stated the query-string is part of the replacement, if any is
present. Most of time, when the doc and the code differ, the code is fixed. But
here, the replace-path action is pretty confusing because the set-path action is
only applied on the path. The query-string is left intact. And the path sample
fetch also ignores the query-string. In addition, the replace-path action is
quite recent. It was added in the 2.2. Thus, exceptionally, the documentation is
fixed instead.

Note that set-pathq and replace-pathq actions and pathq sample fetch will be
added to manipulate the path with the query-string.

This patch must be backported as far as 2.0.
This commit is contained in:
Christopher Faulet 2020-09-02 14:16:59 +02:00
parent 1fa0cc18e1
commit 82c8332be0

View File

@ -5549,8 +5549,9 @@ http-request replace-path <match-regex> <replace-fmt>
This works like "replace-header" except that it works on the request's path This works like "replace-header" except that it works on the request's path
component instead of a header. The path component starts at the first '/' component instead of a header. The path component starts at the first '/'
after an optional scheme+authority. It does contain the query string if any after an optional scheme+authority and ends before the question mark. Thus,
is present. The replacement does not modify the scheme nor authority. the replacement does not modify the scheme, the authority and the
query-string.
It is worth noting that regular expressions may be more expensive to evaluate It is worth noting that regular expressions may be more expensive to evaluate
than certain ACLs, so rare replacements may benefit from a condition to avoid than certain ACLs, so rare replacements may benefit from a condition to avoid
@ -5560,9 +5561,6 @@ http-request replace-path <match-regex> <replace-fmt>
# prefix /foo : turn /bar?q=1 into /foo/bar?q=1 : # prefix /foo : turn /bar?q=1 into /foo/bar?q=1 :
http-request replace-path (.*) /foo\1 http-request replace-path (.*) /foo\1
# suffix /foo : turn /bar?q=1 into /bar/foo?q=1 :
http-request replace-path ([^?]*)(\?(.*))? \1/foo\2
# strip /foo : turn /foo/bar?q=1 into /bar?q=1 # strip /foo : turn /foo/bar?q=1 into /bar?q=1
http-request replace-path /foo/(.*) /\1 http-request replace-path /foo/(.*) /\1
# or more efficient if only some requests match : # or more efficient if only some requests match :