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 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"
Notice: The URL regular expression must match the complete request URL, not just a substring of it. Patterns should usually end with
.*so that URLs with any path and query string are matched.
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=orbase64=must be specified.Notice: When parsing
header=, all whitespace is stripped and each line must be exactlyKey:Valuewith a single colon. Header values that themselves contain a colon (such as URLs) are silently dropped, and spaces inside values are lost.
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.