Package org.microproxy.extras
Class RewriteRules.Rule
java.lang.Object
org.microproxy.extras.RewriteRules.Rule
- Enclosing class:
RewriteRules
One rewrite rule: a URL pattern plus edits.
-
Method Summary
Modifier and TypeMethodDescriptionMatches the URL without its query string.static RewriteRules.RuleA rule for URLs that fully matchurlRegex.Restricts the rule to these methods.static RewriteRules.RuleA rule for URLs that start withprefix(matched literally).removeRequestHeader(String name) Removes a header from matching requests.removeResponseHeader(String name) Removes a header from matching responses.replaceInBody(String regex, String replacement) Replaces every match ofregexin textual response bodies (Matcher.replaceAll(java.lang.String)).replaceLiteralInBody(String target, String replacement) Replaces every occurrence oftargetliterally in textual response bodies.setRequestHeader(String name, String value) Sets a header on matching requests.setResponseHeader(String name, String value) Sets a header on matching responses.
-
Method Details
-
matching
A rule for URLs that fully matchurlRegex.- Parameters:
urlRegex- the regular expression matched against the whole URL- Returns:
- a rule matching the complete URL against the expression
-
prefix
A rule for URLs that start withprefix(matched literally).- Parameters:
prefix- the literal URL prefix to match- Returns:
- a rule matching the literal URL prefix
-
ignoringQuery
Matches the URL without its query string.- Returns:
- this rule
-
methods
Restricts the rule to these methods.- Parameters:
methods- the HTTP methods to match- Returns:
- this rule
-
replaceInBody
Replaces every match ofregexin textual response bodies (Matcher.replaceAll(java.lang.String)).- Parameters:
regex- the regular expression to replacereplacement- the replacement text- Returns:
- this rule
-
replaceLiteralInBody
Replaces every occurrence oftargetliterally in textual response bodies.- Parameters:
target- the literal text to replacereplacement- the replacement text- Returns:
- this rule
-
setRequestHeader
Sets a header on matching requests.- Parameters:
name- the request header namevalue- the replacement header value- Returns:
- this rule
-
removeRequestHeader
Removes a header from matching requests.- Parameters:
name- the request header name to remove- Returns:
- this rule
-
setResponseHeader
Sets a header on matching responses.- Parameters:
name- the response header namevalue- the replacement header value- Returns:
- this rule
-
removeResponseHeader
Removes a header from matching responses.- Parameters:
name- the response header name to remove- Returns:
- this rule
-