htmlBody
Replaces the existing response body with the specified content. (This only works for responses with content-type containing html and a status code containing a body (e.g., 200/500).)
⚠️ Note: Requests without a body, such as 204 and 304 responses, are not affected.
Rule Syntax
txt
pattern htmlBody://value [filters...]| Parameters | Description | Detailed Documentation |
|---|---|---|
| pattern | An expression to match against the request URL | Match Pattern Documentation |
| value | Text or binary content. The following types are supported: • Directory/File Path • Remote URL • Inline/Embedded/Values Content | Operation Instruction Documentation |
| filters | Optional filters. Supports matching: • Request URL/Method/Headers/Content • Response Status Code/Headers | Filter Documentation |
Configuration Example
Inline Method
txt
www.example.com/path htmlBody://(Hello) file://(-test-)
www.example.com/path2 htmlBody://(Hello) file://(-test-) resType://js- Requesting
https://www.example.com/path/toresults in a response ofHello - Requesting
https://www.example.com/path2/toresults in a response of-test-
Inline/Values Method
txt
``` body.txt
Hello world.
```
www.example.com/path htmlBody://{body.txt} file://(-test-)
www.example.com/path2 htmlBody://{body.txt} file://(-test-) resType://css- Requesting
https://www.example.com/path/toresults in a response ofHello world. - Requesting
https://www.example.com/path2/toresults in a response of-test-
Avoiding Non-Standard Requests
When the API response type (Content-Type) is not standardized and returned as text/html, this may result in:
- The front-end mistakenly parsing the API data as HTML
- Injected content corrupts the original data structure
- Triggering front-end parsing errors
Use enable://strictHtml or enable://safeHtml mode to protect non-HTML content:
txt
www.example.com/path1 htmlBody://(test) file://(-test-) enable://strictHtml
www.example.com/path2 htmlBody://(test) file://([-test-]) enable://strictHtml
www.example.com/path3 htmlBody://(test) file://([-test-]) enable://safeHtml
www.example.com/path4 htmlBody://(test) file://(<div>Test</div>) enable://strictHtml- Requesting
https://www.example.com/path1/toresults in a response of-test- - Requesting
https://www.example.com/path2/toresults in a response of[-test-] - Requesting
https://www.example.com/path3/toresults in a response of[-test-] - Requesting
https://www.example.com/path4/toresults in a response oftest
safeHtml/strictHtml feature reference: enable://safeHtml, lineProps://strictHtml
Local/Remote Resources
txt
www.example.com/path1 htmlBody:///User/xxx/test.txt
www.example.com/path2 htmlBody://https://www.xxx.com/xxx/params.txt
# Editing a temporary file
www.example.com/path3 htmlBody://temp/blank.txtAssociated Protocols
- Inject content before the response content (
Prepend To Body): resPrepend - Inject HTML content before the response content (
Prepend HTML To Body, response type must betext/html): htmlPrepend - Inject CSS content before the response content (
Prepend CSS To Body, response type must betext/htmlortext/css): cssPrepend - Inject JS content before the response content (
Prepend JS To Body, response type must betext/html,text/css, orapplication/javascript): jsPrepend - Replace the response content (
Replace Body): resBody - Replace the response content with HTML content (
Replace Body, response type must betext/html): htmlBody - Replace the response content with CSS content (
Replace Body, response type must betext/htmlortext/css): cssBody - Replace the response content with JS content (
Replace Body, response type must betext/html,text/css, orapplication/javascript): jsBody - Append content after the response content (
Append To Body): resAppend - Append HTML content after the response content (
Append HTML To Body, response type must betext/html): htmlAppend - Append CSS content after the response content (
Append CSS To Body, response type must betext/htmlortext/css): cssAppend - Append JS content after the response content (
Append JS To Body, response type must betext/html,text/css, orapplication/javascript): jsAppend - Replace the response content using keywords or regular expressions (
Modify Body Text): resReplace - Override JSON/Form objects in the response content (
Modify Form/JSON): resMerge - Delete a property from a JSON/Form object in the response content (
Delete Form/JSON): delete://resBody.xxx - Validate the HTML content format: enable://safeHtml, lineProps://strictHtml