Mock Response

Chute can return mock data for matched HTTP/HTTPS requests without reaching the real server. This is useful for testing, development, or blocking unwanted content with a custom response.

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

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

Map Local Format

For serving mock responses from local files or with base64-encoded content:

[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"

Map Local Parameters

Parameter Description
data="/path/to/file" File path to serve as response body. The file is read at request time.
base64="<encoded>" Base64-encoded response body content.
header="<base64>" Base64-encoded custom response headers (Key: Value\n format).

At least one of data= or base64= must be specified.

Template Variables

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

Variable Replaced With
{{url}} Full request URL path
{{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 rules for HTTPS traffic without MitM will be ignored.

S. Smart Rabbit LLC © All Rights Reserved            updated 2026-07-28 17:49:04

results matching ""

    No results matching ""