Mock Response

Chute can return mock data for matched HTTP/HTTPS requests. For decrypted HTTP/2 streams the mock response is answered locally without forwarding the request; for HTTP/1.1 requests (plain proxying and MitM HTTP/1.1) the request is still sent to the real server, and the real response is replaced with the mock data before it reaches the client. This is useful for testing, development, or blocking unwanted content with a custom response.

Mock Response rules are defined in the [Map Local] section.

Only one Mock Response rule is applied per request — the first rule whose URL pattern matches.

Map Local Format

For serving mock responses from local files, inline text or base64-encoded content, with a chosen status code and headers:

[Map Local]
^https://example\.com/api.* data="/path/to/mock-response.json"
^https://example\.com/page.* data="/path/to/page.html" header="SGVhZGVyOiBWYWx1ZQ=="
^https://example\.com/pixel.* base64="R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
^https://example\.com/api/v2.* data-type=text data="rate limited" status-code=429 header="Content-Type: text/plain|Retry-After: 30"
^https://example\.com/beacon.* data-type=tiny-gif

Notice: The regular expression is matched anywhere in the request's full URL — https://… once decrypted, http://… when Chute is a plain HTTP proxy — so ^https://example\.com already covers every path and query string under that host and a trailing .* is unnecessary. It is never matched against the path alone, so a pattern such as ^/api does not match. The pattern keeps its case, so \S, \D, \W and \B mean what they say; the match itself ignores case.

A # or // at the start of the line or after a space begins a comment that runs to the end of the line, unless it is inside double quotes; ; never does. See Comment.

Map Local Parameters

Parameter Description
data="/path/to/file" A file path to serve as the response body, read at request time — or, with data-type, the body itself (see below).
`data-type=file\ text\ base64\ tiny-gif` How data= is read: file, a path (the default); text, the value is the body; base64, the value is base64-decoded; tiny-gif, a built-in 1×1 GIF with no data= needed (sent as image/gif unless header= sets a Content-Type).
base64="<encoded>" Base64-encoded response body content (the same as data-type=base64).
status-code=<code> Status code of the mock response, 200–599. Default 200. A code outside that range makes the whole line invalid, and it is reported as a configuration error.
`header="Key: value\ Key2: value2"` Custom response headers. Pairs are separated with `\ , and each pair splits at its first colon, so a value may itself contain colons (URLs). The older base64 form (Key:Value\n` lines, base64-encoded) is still accepted.

A rule needs a body: data= (a file, or text or base64 with data-type), base64=, or data-type=tiny-gif; data-type=text without data= gives an empty body. A rule that cannot produce its body — no body parameter, or a file that cannot be read — does not answer: the request goes on to the server, and later Mock Response rules are not tried.

Notice: In either form, each header splits at its first colon, and the name and value are trimmed of surrounding spaces; a line without a colon is ignored.

Answers Chute generates itself — Map Local, a script's response, and the answers and error page of URL Rewrite and the REJECT policies — follow HTTP: the answer to a HEAD request is the header alone, with the Content-Length a GET would get, and an answer with status 204, 205 or 304 carries neither a body nor a Content-Length.

Template Variables

When using data= or base64=, the response body supports template variable substitution:

Variable Replaced With
{{url}} The full request URL, as the rule saw it
{{host}} Request hostname
{{path}} Relative URL path
{{method}} HTTP method
{{ua}} User-Agent header value

Example mock response file (response.json):

{
    "requested_url": "{{ "{{url}}" }}",
    "host": "{{ "{{host}}" }}",
    "method": "{{ "{{method}}" }}"
}

Note: For HTTPS requests, MitM decryption must be enabled for the matching hostname. Mock Response rules for HTTPS traffic without MitM will be ignored. A plain HTTP request is answered only when it reaches Chute through its HTTP proxy; plain HTTP that arrives through the TUN interface is forwarded untouched. Chute Android sends all traffic through TUN unless System HTTP Proxy is turned on in Settings, which hands apps Chute's HTTP proxy (Android 10 and later; off by default).

Notice: The file behind data= is read by the device that runs Chute, at request time. When you add a Mock Response rule from Chute Dashboard to an iPhone, a path on your Mac is meaningless to the phone — put the content inline with base64= instead, or serve the file from a URL and use URL Rewrite.

S. Smart Rabbit LLC © All Rights Reserved            updated 2026-09-25 00:02:29

results matching ""

    No results matching ""