Answer a request with a file
Give an app the answer that you want from a file of your computer. The server is not asked, so you can work with data that it does not have yet, or without it.
On this page
Make the rule
- Right-click a request and choose Answer it with a file…
- Press Choose the file… and choose it.
- Change the Status if you need another than
200. It goes from 100 to 599. - Leave Content type empty to use the one of the name of the file, or write it, such as
application/json. - Look at the addresses that it fits and press Keep the rule.
The next time that the app asks for that address, it gets the file. The request says rule in the list, and Answered from … when you open it.
Change the answer
Edit the file and save it. TotalTraffic reads it each time, so the next request has the new content.
To start from the real answer, choose the request, copy the body in Answer, and paste it in a new file.
What to know
- The file can have up to 64 MB.
- The type is known for JSON, HTML, JavaScript, CSS, text, XML, SVG, PNG, JPEG, GIF, WebP, icons, WOFF2 fonts, PDF and WebAssembly. For others, write it.
- The answer has no other headers than its type and its length. A browser that asks from a page of another domain refuses it, because the headers that allow it are not there.
- An answer from a file is not paused, even if another rule pauses the answers of that address.
If you move or delete the file, the app gets an error 502 that says so. Change the rule, or remove it.