Class RewriteRules.Rule

java.lang.Object
org.microproxy.extras.RewriteRules.Rule
Enclosing class:
RewriteRules

public static final class RewriteRules.Rule extends Object
One rewrite rule: a URL pattern plus edits.
  • Method Details

    • matching

      public static RewriteRules.Rule matching(String urlRegex)
      A rule for URLs that fully match urlRegex.
      Parameters:
      urlRegex - the regular expression matched against the whole URL
      Returns:
      a rule matching the complete URL against the expression
    • prefix

      public static RewriteRules.Rule prefix(String prefix)
      A rule for URLs that start with prefix (matched literally).
      Parameters:
      prefix - the literal URL prefix to match
      Returns:
      a rule matching the literal URL prefix
    • ignoringQuery

      public RewriteRules.Rule ignoringQuery()
      Matches the URL without its query string.
      Returns:
      this rule
    • methods

      public RewriteRules.Rule methods(String... methods)
      Restricts the rule to these methods.
      Parameters:
      methods - the HTTP methods to match
      Returns:
      this rule
    • replaceInBody

      public RewriteRules.Rule replaceInBody(String regex, String replacement)
      Replaces every match of regex in textual response bodies (Matcher.replaceAll(java.lang.String)).
      Parameters:
      regex - the regular expression to replace
      replacement - the replacement text
      Returns:
      this rule
    • replaceLiteralInBody

      public RewriteRules.Rule replaceLiteralInBody(String target, String replacement)
      Replaces every occurrence of target literally in textual response bodies.
      Parameters:
      target - the literal text to replace
      replacement - the replacement text
      Returns:
      this rule
    • setRequestHeader

      public RewriteRules.Rule setRequestHeader(String name, String value)
      Sets a header on matching requests.
      Parameters:
      name - the request header name
      value - the replacement header value
      Returns:
      this rule
    • removeRequestHeader

      public RewriteRules.Rule removeRequestHeader(String name)
      Removes a header from matching requests.
      Parameters:
      name - the request header name to remove
      Returns:
      this rule
    • setResponseHeader

      public RewriteRules.Rule setResponseHeader(String name, String value)
      Sets a header on matching responses.
      Parameters:
      name - the response header name
      value - the replacement header value
      Returns:
      this rule
    • removeResponseHeader

      public RewriteRules.Rule removeResponseHeader(String name)
      Removes a header from matching responses.
      Parameters:
      name - the response header name to remove
      Returns:
      this rule