Contents

NetPeek for iOS

Rewrite and mock

Match conditions and actions in Simple mode or the expert DSL: headers, bodies, mock, block, redirect, Map Local.

A rewrite rule is a condition (when it applies) plus one or more actions (what to do). Rules run in the tunnel without modifying the app under test. They must be saved and enabled, and the global Rewrite gate must be on. Verify with a new request.

Simple mode

Swipe a Recent Requests row → New rewrite (host and path prefilled), or tap + in the rewrite list. Choose when it applies, then one of six intents:

IntentEffect
Edit HeaderAdd, change, or delete a request or response header.
Edit BodyReplace text in the request or response body.
Mock responseSkip the origin and return custom content.
Block requestEmpty response, empty JSON object/array, or empty image.
RedirectSend the client to another URL (for example production → staging).
Local fileServe a file on the device as the response (Map Local).

Multiple Simple-mode conditions are combined with AND. For OR, create another rule with the same action. Expert mode is for multiple actions, parentheses, and regular expressions.

Expert DSL

The first token of an action (^ replace/insert, ~ delete, or an @ verb) selects what to do; @req.* / @rsp.* selects where; quoted strings hold values. Use ASCII " quotes — curly quotes fail silently.

ConditionMeaning
@req.hostRequest host
@req.apiPath
@req.url / @req.query / @req.methodFull URL, query string, HTTP method
@req.header["Name"] / @req.bodyTextRequest header or body
@rsp.status / @rsp.bodyTextResponse status or body

Operators include ==, !=, CONTAINS, BEGINSWITH, ENDSWITH, LIKE, MATCHES, IN. Logic uses &&, ||, !, and parentheses.

ActionExample
^ replace/insert^@req.header["X-Debug"] "1"
~ delete~@req.header["Authorization"]
@mock@mock "{\"ok\":true}"
@reject / @reject-img / @reject-dict / @reject-array@reject-array
@redirect or @301@308@redirect 307 "https://staging/x"
@map-local@map-local "/shared/mock.json"
@break@break

URL and method. ^@req.host, ^@req.api, and ^@req.method cannot change the URL or method. Executable actions cover headers, bodies, status, mock, reject, redirect, Map Local, and break.