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.
Mutiple rules could be applied for one single request. The first mock with a matching URL pattern is used.
[Mock]
^http://example\.com/api/status status=200 body={"ok":true}
^http://example\.com/blocked status=403
^http://ad\.com/.* status=200 body="<html></html>" content-type="text/html"
The mock rule consists of 3+ parts: URL regular expression, and one or more key=value response parameters.
Parameters
status: Required.
status=200
The HTTP status code to return.
body: Optional.
body={"result":"mocked"}
The response body to return. If not specified, an empty body is returned.
content-type: Optional.
content-type=application/json
The Content-Type header for the mock response. Use together with body to serve proper responses.
headers: Optional.
headers=X-Custom:Value1;X-Another:Value2
Additional response headers, separated by ;.
Note: For HTTPS requests, MitM decryption must be enabled for the matching hostname. Mock rules for HTTPS traffic without MitM will be ignored.