Rules
A rule says what to do with requests that match it: answer with a response you write, reply with a file, send them to another server, change them on the way, pause them, or fail them on purpose. Rules are part of Wirescry Pro.
How rules apply
The Rules tab lists your rules in order. For each request, the first enabled rule that matches handles it, and no other rule runs. A request no rule matches passes through as usual.
- Use the ↑ and ↓ buttons to reorder rules, and the checkbox on each row to turn one off without deleting it.
- Put specific rules above broad ones. A Pause rule below a Mock rule for the same request never fires.
- A rule that matches applies every time, not once.
A request a rule handled shows a Rule badge in the traffic list and Handled by in its details, and rule= finds it. Rules see HTTP requests only; WebSocket connections always pass through.
To start a rule from a request you've captured, select it and choose Mock… or Pause next time… in its details or its right-click menu. The Rules tab opens with a new rule that matches that request (its method, host, exact path and query parameters), filled in from it. Nothing changes until you click Add rule.
Conditions
A request must meet every condition you set, and a rule needs at least one. To match every request, enter * as the host.
| Condition | How it matches |
|---|---|
| Method | Any, or one of GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS. |
| Host | Ignoring case; * matches any run of characters: api.example.com, *.example.com. No port. *.example.com doesn't match example.com itself. |
| Path | Without the query string. * matches anything, slashes included: /api/*/users. Without a * it must match exactly. Case-sensitive. |
| Path regex | Instead of a path: a regular expression tested against the path and query, e.g. ^/items/\d+$. Case-sensitive. |
Under More conditions:
| Condition | How it matches |
|---|---|
| Query | One per line. name=value (value with * wildcards), name for any value, name= for an empty one. Other parameters are ignored. |
| Headers | One per line. Name: value (ignoring case, with *), or Name for any value. |
| Body contains | Exact text, case-sensitive. |
| Body JSON | JSON the body must contain, e.g. {"action": "login"}. Fields you leave out are ignored, and each array item must match some item in the body's array. |
Body conditions see a request body only when it has a Content-Length of 64 KB or less, so chunked or streamed uploads never match them. Bodies compressed with gzip, deflate or Brotli are decoded first.
Path regexes run on a linear-time engine, so a pattern can't slow the proxy down: backreferences and lookarounds are refused, and a path and query over 2 KB never matches. Up to 50 rules can use one.
Actions
| Action | What the client gets |
|---|---|
| Mock a response | The status, headers and body you write. The server is never contacted. |
| Reply with a file | The status and headers you write, with a file from your computer as the body. |
| Pass through | The real server's response, unchanged. Useful above a broader rule, to exempt some requests from it. |
| Forward to another server | The response from another server you name. |
| Pass through and rewrite | The real server's response, with the changes you set on the request, the response, or both. |
| Pause to inspect and edit | Whatever you decide in the Breakpoints tab. |
| Close the connection | The connection closes without a response. |
| Time out (never answer) | Nothing: the request hangs until the client gives up. |
Every action except pause, close and time out can wait first: Delay takes 0 to 600,000 milliseconds (10 minutes). Requests that close or time out show as failed in the traffic list, with Rule as the reason.
Mock a response
Set the Status (200 to 599), Response headers (one Name: value per line) and Body, as text up to 256 KB. A new rule starts as a 200 with content-type: application/json and {}. For binary data, use Reply with a file. Mock… from a captured request copies its status, headers and, when it's text, its body.
Reply with a file
Choose a file with Choose… or type its full path. The file is read again for each request, so your edits show up straight away, and it can be up to 50 MB. Set its Content-Type in the headers; Wirescry doesn't guess it.
The editor warns you if there's no file at that path, or it's a folder, too large or unreadable, but saves the rule anyway. While the file is missing, clients get a 404 that says so; other problems give a 500. Neither shows the file's path. Network paths (\\server\share) and Windows device names aren't allowed.
Forward to another server
To is just a scheme, host and port, such as http://localhost:3000; the request keeps its own path and query. The Host header changes to the new server's, unless you tick Keep Host, for servers that route by name.
Pass through and rewrite
Change any of these, and the request still goes to the real server:
- Request headers:
Name: valuesets one,Name:with no value removes it. Host can't be rewritten; use Forward for that. - New request body, replacing the whole body.
- Response status, response headers, and a new response body.
Replacement bodies are text up to 256 KB. A rewrite replaces whole bodies; it can't edit part of one.
Limits
- Status codes are 200 to 599. A 204, 205 or 304 can't have a body.
- Header values are one line of plain text: no emoji or other characters outside Latin-1. Content-Length, Transfer-Encoding, Connection and similar headers are set automatically and can't be set by a rule.
- Up to 1,000 rules, and 20 query or header conditions per rule.
- Rules are a debugging tool, not a security control: a client can often reach the same thing by another URL.
Import and export
Export saves all your rules as a JSON file to share or keep. Import adds the rules from such a file after your own, without replacing any. Imported rules arrive switched off, because a rule from someone else could send your traffic to another server or serve your files to any website: check each one before you turn it on.
Your rules are saved as rules.json in the plugins/pro folder of Wirescry's data folder. If Pro's license lapses, your rules are kept, and come back when it's active again.