Custom rules are used to give better control over HTTP Proxy message handling, and as an interface to the HTTP Proxy JavaScript API.
When Use Custom Rules is selected, every incoming message is checked against the rules. Only if none of the rules match the message, is the default operating mode used (see Setting Operating Modes).
Rules are tested serially, from top to bottom, until a matching rule is found. A rule is considered to match only if its condition matches, and it has an action. Once a matching rule is found no further rules are checked.
This field determines which part of the message HTTP Proxy should try to match.
Match a string of the form host:port (this is always the web-server address). Host may be an IP address, if Reverse DNS is not enabled, or if it failed. |
|
Match the value of a specific header, given in the Header Name field. |
|
This field determines whether the rule can match requests, responses, or both (select *).
This field is only used if the Match Object is Header; otherwise it is ignored.
It specifies the name of the header whose value will be matched. The drop down lists supplies commonly used headers, but you may use any name.
Enter a regular expression. HTTP Proxy will match it against the object determined by the previous fields. Almost any valid PERL5-compatible regular expression may be used (the actual syntax is from java.util.regex.Pattern).
There are four basic actions.
Hold the message (as if Manual Mode was selected) |
|
Pass the message on (as if Automatic Mode was selected) |
|
In addition, any functions defined using the HTTP Proxy JavaScript API will also appear as possible actions. When the condition matches for a rule with a javascript action, the selected function will be called, and its return value will be used as the actual action.
The current ruleset will be automatically stored in a file named defaultRules.rules in the Template Directory when HTTP Proxy exits. If the file exists, it will be automatically loaded when HTTP Proxy starts.
You may also store rules on demand and load them as needed, using the button in the Custom Rules window.