Class ModifyBody.Rule

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

public static final class ModifyBody.Rule extends Object
One rule: a regular expression to replace in the bodies a filter selects.
  • Method Details

    • of

      public static ModifyBody.Rule of(FlowFilter filter, String regex, String replacement)
      A rule that replaces regex with the literal replacement.
      Parameters:
      filter - the messages to edit
      regex - the regular expression, matched against the decoded body's bytes
      replacement - the replacement text, inserted as UTF-8
      Returns:
      the rule
      Throws:
      IllegalArgumentException - if the regular expression is invalid
    • parse

      public static ModifyBody.Rule parse(String spec)
      Parses a spec of the form [|flow-filter]|regex|[@]replacement.
      Parameters:
      spec - the spec, starting with its separator
      Returns:
      the rule
      Throws:
      IllegalArgumentException - if the spec is invalid or its file cannot be read
    • filter

      public FlowFilter filter()
      Returns the messages this rule edits.
      Returns:
      the messages this rule edits
    • pattern

      public Pattern pattern()
      Returns the regular expression, over the body's bytes as ISO-8859-1 characters.
      Returns:
      the regular expression, over the body's bytes as ISO-8859-1 characters