### Configuration Example for responseFor Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/responseFor.md An example demonstrating how to configure the responseFor rule to set custom ServerIPs for a specific domain. Multiple IPs can be provided, separated by commas. ```txt www.example.com/path responseFor://1.1.1.1,2.2.2.2 ``` -------------------------------- ### Remote Rule File Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This example shows how to load attachment rules from a remote URL by referencing a rule file containing multiple attachment configurations. ```txt @https://remote-url/xxx.txt ``` -------------------------------- ### Delete Rule Configuration Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/delete.md Provides examples of how to configure the delete rule for different scenarios, such as deleting cookies and response body content based on URL patterns. ```txt https://www.example.com/path delete://reqCookies.token|resCookies.token https://raw.githubusercontent.com/avwo/whistle/refs/heads/master/package.json delete://resBody.name resType://json ``` -------------------------------- ### Basic Attachment Rule Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This basic example configures a rule to automatically download a file named 'example.html' when a user visits the homepage of example.com. ```txt https://www.example.com/ attachment://example.html ``` -------------------------------- ### HTTP/HTTPS Conversion Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/inherit.md Demonstrates how to convert HTTP and HTTPS requests to a different domain, showing automatic path concatenation by default. ```txt http://www.example.com/path1 www.test.com/path/xxx https://www.example.com/path2 www.abc.com/path3/yyy ``` -------------------------------- ### Example Remote Rule File Content Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/@.md This is an example of the content expected within an external rule file imported using the @ symbol. It follows standard Whistle rule syntax. ```txt # Example of a remote rule file www.example.com proxy://127.0.0.1:8080 api.example.com resCors://* static.example.com cache://3600 ``` -------------------------------- ### Attachment Rule with Filters Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This example demonstrates how to trigger a PDF download only when a specific query parameter 'download=true' is present in the request URL. ```txt https://api.example.com/document attachment://User-Manual.pdf includeFilter:///[?&]download=true/ ``` -------------------------------- ### Detailed Configuration Mode with JSON File Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Applies detailed CORS settings defined in a JSON file. This example also shows how to exclude OPTIONS requests. ```cors.json origin: * methods: POST headers: x-test credentials: true maxAge: 300000 ``` ```txt www.example.com/path resCors://{cors.json} # Do not process OPTIONS requests www.example.com/path2 resCors://{cors.json} excludeFilter://m:options ``` -------------------------------- ### WebSocket Rule Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/frameScript.md Example configuration applying a frameScript rule to a WebSocket connection. The script 'test-frame.js' is loaded to handle frame manipulation. ```txt wss://echo.websocket.org/ frameScript://{test-frame.js} ``` -------------------------------- ### Manually Install Root Certificate on Alpine Linux Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md On Alpine Linux, install the 'ca-certificates' package, then manually install the Whistle root certificate by copying the 'rootCA.crt' file and updating the system's CA certificates. ```bash sudo apk add ca-certificates sudo cp rootCA.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates ``` -------------------------------- ### resReplace Inline Mode Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resReplace.md Demonstrates inline replacement using a simple key-value pair and a regular expression for dynamic replacement. The request URL is matched, and the response body is transformed. ```txt www.example.com/path file://(00user-11test-22user-33test) resReplace://user=abc&/\d+/g=number ``` -------------------------------- ### Verify Root Certificate Installation with curl Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md After installing the root certificate, verify its functionality by setting the HTTPS proxy and making a curl request to an HTTPS URL. ```bash # Set proxy and test HTTPS request export https_proxy=http://127.0.0.1:8899 curl https://example.com ``` -------------------------------- ### Basic Socks Proxy Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/socks.md Examples of configuring a SOCKS5 proxy using IP addresses or domain names. The default port 443 is used if not specified. ```txt # Proxy requests to a SOCKS5 proxy: `127.0.0.1:443` www.example.com/path socks://127.0.0.1 # Default port 443 # Proxy all requests for the current domain to the SOCKS5 proxy: `127.0.0.1:8080` www.example.com socks://127.0.0.1:8080 # You can also use a domain name. www.example.com/path socks://test.proxy.com # Default port 443 www.example.com socks://test.proxy.com:8080 ``` -------------------------------- ### Install Whistle Root Certificate with w2 CLI Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md Use 'w2 ca' to manage the Whistle root certificate. This command can install the certificate locally, download it from a specified port and IP/domain, from a URL, or from a local file path. ```bash w2 ca ``` ```bash w2 ca 8080 ``` ```bash w2 ca www.test.com:8080 ``` ```bash w2 ca certUrl ``` ```bash w2 ca localCertPath ``` -------------------------------- ### Inline HTML Body Content Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Example of using the htmlBody rule with inline content for different paths. ```txt www.example.com/path htmlBody://(Hello) file://(-test-) www.example.com/path2 htmlBody://(Hello) file://(-test-) resType://js ``` -------------------------------- ### Manually Install Root Certificate on Ubuntu/Debian Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md On Ubuntu/Debian systems, manually install the Whistle root certificate by copying the 'rootCA.crt' file and updating the system's CA certificates. ```bash sudo cp rootCA.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates ``` -------------------------------- ### CORS Object Structure Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Illustrates the structure of a CORS object, defining various CORS-related parameters. ```text origin: * methods: POST headers: x-test credentials: true maxAge: 300000 ``` -------------------------------- ### Manually Install Root Certificate on CentOS/RHEL/Fedora Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md On CentOS/RHEL/Fedora systems, manually install the Whistle root certificate by copying the 'rootCA.crt' file to the anchors directory and updating the system's CA trust. ```bash sudo cp rootCA.crt /etc/pki/ca-trust/source/anchors/ sudo update-ca-trust ``` -------------------------------- ### Setting Multiple Request Headers from JSON Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqHeaders.md Configures multiple request headers by referencing a JSON file. This is useful for managing a collection of headers efficiently. The JSON content is directly embedded in the example. ```json x-test1: 1 x-test2: x-test3: abc ``` ```txt www.example.com/path2 reqHeaders://{test.json} ``` -------------------------------- ### Combining Multiple Filter Conditions Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/gui/network.md Combine multiple filter conditions using 'AND' logic to narrow down search results. This example demonstrates filtering by body content, request method, status code, and host header. ```txt b:/"success":false/ m:POST s:200 H:api.example.com ``` -------------------------------- ### JavaScript Frame Manipulation Script Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/frameScript.md Example JavaScript code for frameScript. It demonstrates sending preset data to the server and client, and processing incoming frames. ```javascript // Send preset data ctx.sendToServer('1 = 0x12300000'); ctx.sendToClient('1 = 0x1236666666'); // Process the data frame sent to the server ctx.handleSendToServerFrame = function(buf, opts) { // Can return empty, null, undefined, etc. return (buf + '').replace(/1/g, '***'); }; // Process the data frame sent to the client ctx.handleSendToClientFrame = function(buf, opts) { // Can return empty, null, undefined, etc. return (buf + '').replace(/1/g, '+++'); }; ``` -------------------------------- ### Setting Script Tag Attributes Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/jsBody.md Use the lineProps parameter to set attributes for injected script tags. Examples include nomodule, module, defer, async, and crossorigin. ```txt www.example.com/path1 jsBody://https://www.xxx.com/xxx/params.js lineProps://nomodule www.example.com/path2 jsBody://https://www.xxx.com/xxx/params.js lineProps://module www.example.com/path3 jsBody://https://www.xxx.com/xxx/params.js lineProps://defer www.example.com/path4 jsBody://https://www.xxx.com/xxx/params.js lineProps://async www.example.com/path5 jsBody://https://www.xxx.com/xxx/params.js lineProps://crossorigin ``` -------------------------------- ### Configure Display Text and Help Links for Hints Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Enhance hints by providing `displayText` for custom display and an optional `help` URL for additional information, accessible via F1. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintList": [ { "text": "test1", "displayText": "displayText1" }, { "text": "test2", "displayText": "displayText2" }, { "text": "test3", "displayText": "displayText3", "help": "https://www.example.com/path" } ] } } ... ``` -------------------------------- ### Import Local Project Rules with @ Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/@.md Import rules from local file paths. Supports absolute paths and paths relative to the user's home directory using '~'. ```txt @C:/whistle/rules.txt ``` ```txt @D:\config\proxy.rules ``` ```txt @/Users/username/projects/my-app/whistle-config.txt ``` ```txt @~/dev/configs/rules.txt ``` -------------------------------- ### Load from File Path for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Load content to prepend from a local file path. Ensure the path is correctly specified. ```txt # Load from a local file pattern resPrepend:///User/xxx/header.html ``` -------------------------------- ### Basic resHeaders Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resHeaders.md Adds a single response header 'x-proxy' with the value 'Whistle' to requests matching 'www.example.com/path'. ```txt www.example.com/path resHeaders://x-proxy=Whistle ``` -------------------------------- ### Loading Response Headers from Local or Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resHeaders.md Demonstrates using local file paths, remote URLs, or temporary files to define response headers. ```txt www.example.com/path1 resHeaders:///User/xxx/test.json ``` ```txt www.example.com/path2 resHeaders://https://www.xxx.com/xxx/params.json ``` ```txt # Editing a temporary file www.example.com/path3 resHeaders://temp/blank.json ``` -------------------------------- ### Use Backend Interface for Hints Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Configure `hintUrl` in `whistleConfig.pluginVars` to fetch hints dynamically from a backend API, offering a more flexible way to manage suggestions. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintSuffix": [ "=", ".key1=123", ".key2" ], "hintUrl": "/cgi-bin/plugin-vars" } } ... ``` -------------------------------- ### Load CORS Configuration from Local or Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Demonstrates loading CORS configurations from local file paths or remote URLs, including temporary files. ```txt www.example.com/path1 resCors:///User/xxx/test.json www.example.com/path2 resCors://https://www.xxx.com/xxx/params.json # Editing a temporary file www.example.com/path3 resCors://temp/blank.json ``` -------------------------------- ### Basic Request Header Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqHeaders.md Sets a single request header 'x-proxy' with the value 'Whistle' for matching URLs. Use this for simple header injections. ```txt www.example.com/path reqHeaders://x-proxy=Whistle ``` -------------------------------- ### resReplace Local and Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resReplace.md Illustrates how to configure resReplace to use replacement rules defined in local files or fetched from remote URLs. It also shows the usage of a temporary file for configuration. ```txt www.example.com/path1 resReplace:///User/xxx/test.json ``` ```txt www.example.com/path2 resReplace://https://www.xxx.com/xxx/params.json ``` ```txt www.example.com/path3 resReplace://temp/blank.json ``` -------------------------------- ### Configure Hint Suffixes for Key Names Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Use `hintSuffix` to define common suffixes that can be appended to a plugin variable key, providing quick access to related configurations. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintList": [ { "text": "test1", "displayText": "displayText1" }, { "text": "test2", "displayText": "displayText2" }, { "text": "test3", "displayText": "displayText3", "help": "https://www.example.com/path" } ], "hintSuffix": [ "=", ".key1=123", ".key2" ] } } ... ``` -------------------------------- ### Filter Conditions Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/gui/network.md Demonstrates the syntax for various filter conditions supported in the settings, including matching request URLs, methods, headers, and client IPs. ```txt .example.com ``` ```txt m:POST ``` ```txt h:/cookie:[^\r\n]*test=123/ ``` ```txt H:example.com H:/test/i ``` ```txt i:11.2 i:/^11\.2/ ``` -------------------------------- ### HTML Body from File Content Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Demonstrates using the htmlBody rule with content defined in a separate file, supporting different response types. ```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 ``` -------------------------------- ### Referencing Local and Remote Header Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqHeaders.md Demonstrates how to specify request headers using local file paths or remote URLs. Supports direct file paths, absolute URLs, and temporary file references. ```txt www.example.com/path1 reqHeaders:///User/xxx/test.json www.example.com/path2 reqHeaders://https://www.xxx.com/xxx/params.json # Editing a temporary file www.example.com/path3 reqHeaders://temp/blank.json ``` -------------------------------- ### Load from Remote URL for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Load content to prepend from a remote URL. This is useful for including external scripts or resources. ```txt # Load from a remote URL pattern resPrepend://https://cdn.example.com/analytics-script.js ``` -------------------------------- ### Equivalent ResHeaders Rule Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This demonstrates how the attachment protocol is equivalent to manually setting the 'content-disposition' header using the resHeaders protocol. ```txt https://www.example.com/ resHeaders://content-disposition=attachment;filename="example.html" ``` -------------------------------- ### HTML Body from Local and Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Shows how to use the htmlBody rule to load content from local file paths or remote URLs. ```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.txt ``` -------------------------------- ### Quick Mode: Allow All Origins Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Sets the Access-Control-Allow-Origin header to '*' for all requests matching the pattern. This configuration does not support cookies. ```txt www.example.com/path resCors://* ``` -------------------------------- ### Quick Mode: Allow Cookies Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Enables cookies for cross-origin requests by setting Access-Control-Allow-Origin to the request's origin and Access-Control-Allow-Credentials to true. ```txt # `enable` sets `access-control-allow-origin: http://reqOrigin` based on the request header `origin` # and settings access-control-allow-credentials: true www.example.com/path2 resCors://enable ``` -------------------------------- ### Load from Temporary File for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Use Whistle's temporary file feature to load content that may require frequent editing. Content is entered via a pop-up dialog. ```txt pattern resPrepend://temp/blank.txt ``` -------------------------------- ### Configure Anonymous Key Value Hints Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Provide a `hintList` in `whistleConfig.pluginVars` to offer predefined values when a plugin variable is prompted. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintList": [ "test1", "test2", "test3" ] } }, ... } ``` -------------------------------- ### Mixed Usage of @ Symbol for Rule Imports Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/@.md Combine multiple rule sources, including remote URLs and local files, to create a comprehensive set of proxy rules. ```txt # Import team-shared base rules @https://team.example.com/configs/base-rules.txt # Import personal project-specific rules @~/projects/my-app/whistle-overrides.txt ``` -------------------------------- ### Set System Proxy with w2 CLI Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md Use 'w2 proxy' to set the system proxy. Specify the IP and port, or a domain with a port. If Whistle is not running, the default port 8899 is used. ```bash w2 proxy ``` ```bash w2 proxy 0 ``` ```bash w2 proxy 8100 ``` ```bash w2 proxy www.test.com:8100 ``` -------------------------------- ### Socks Rule Application with URL Substitution Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/socks.md Illustrates how the socks rule applies to the Final URL after substitution. If the Final URL is empty, it applies to the original request URL. Multiple rules may be needed for chained substitutions. ```txt www.example.com/api www.example.com proxy://127.0.0.1:1234 # To ensure the rule also applies to the substituted request: www.example.com/api www.example.com www.example.com proxy://127.0.0.1:1234 ``` -------------------------------- ### reqType Shortcut Commands Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqType.md Use shortcut commands for common media types without specifying the full MIME type. The charset can be optionally appended. ```plaintext www.example.com/path reqType://form # Without encoding, the `content-type` request header becomes `application/x-www-form-urlencoded` ``` ```plaintext www.example.com/path reqType://json;charset=utf8 # With encoding, the `content-type` request header becomes `application/json;charset=utf8` ``` -------------------------------- ### resType Shortcut Commands Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resType.md Uses shortcut commands for common media types, automatically inferring the full type based on mime lookup. The charset can be specified directly. ```txt # The `content-type` response header without encoding becomes `text/html` www.example.com/path resType://html ``` ```txt # The `content-type` response header with encoding becomes `application/json;charset=utf8` www.example.com/path resType://json;charset=utf8 ``` -------------------------------- ### Local and Remote CSS Body Replacement Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/cssBody.md Illustrates replacing the response body with content from a local file path or a remote URL, specifically for CSS resources. ```txt www.example.com/path1 cssBody:///User/xxx/test.css www.example.com/path2 cssBody://https://www.xxx.com/xxx/params.css # Editing a temporary file www.example.com/path3 cssBody://temp/blank.css ``` -------------------------------- ### Rule Syntax for responseFor Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/responseFor.md Defines the basic syntax for the responseFor rule, including pattern matching and custom IP specification. Loading data from files or remote URLs for the IP is not supported. ```txt pattern responseFor://ip [filters...] ``` -------------------------------- ### Test Authentication and Authorization Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/replaceStatus.md Simulate unauthenticated access (401) or insufficient permissions (403). Note that 401 may trigger browser authentication popups unless disabled. ```txt # Test unauthenticated access. www.example.com/protected replaceStatus://401 ``` ```txt # Test insufficient permissions. www.example.com/admin replaceStatus://403 ``` -------------------------------- ### Reference Value from Panel for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Reference content stored in the Values panel using a key. This is suitable for large or frequently reused content. ```txt pattern resPrepend://{key-of-values} [lineProps...] [filters...] ``` -------------------------------- ### Test Maintenance Mode Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/replaceStatus.md Simulate a system under maintenance page by returning a 503 status code with custom response body content. ```txt # Test maintenance page. www.example.com replaceStatus://503 resBody://(

System Under Maintenance...

) ``` -------------------------------- ### Setting Multiple Response Headers from JSON Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resHeaders.md Sets multiple response headers based on the content of a 'test.json' file. The headers are defined within the JSON content. ```txt ``` test.json x-test1: 1 x-test2: x-test3: abc ``` www.example.com/path2 resHeaders://{test.json} ``` ```txt # Equivalent to: www.example.com/path2 resHeaders://x-test1=1&x-test2=&x-test3=abc ``` ```txt x-test1: 1 x-test2: x-test3: abc ``` -------------------------------- ### resReplace Inline Mode with JSON Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resReplace.md Shows how to use an inline JSON object to define replacements, supporting both string values and regular expressions. This configuration is applied to requests matching the specified pattern. ```txt www.example.com/path file://(00user-11test-22user-33test) resReplace://{resReplace.json} ``` -------------------------------- ### Advanced Socks Proxy Usage - Force Direct IP Access Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/socks.md Demonstrates how to force the SOCKS5 proxy to access a specific target IP directly, bypassing DNS resolution. This can be achieved using query parameters or enabling directives. ```txt # Using query parameters www.example.com socks://127.0.0.1:8080?host=1.1.1.1 www.example.com socks://127.0.0.1:8080?host=1.1.1.1:8080 # Enabling via directives www.example.com socks://127.0.0.1:8080 1.1.1.1 enable://proxyHost www.example.com socks://127.0.0.1:8080 1.1.1.1:8080 enable://proxyHost ``` -------------------------------- ### Specify Filename Inline Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md Use this syntax to directly specify the desired filename for the downloaded attachment in the rule. ```txt https://example.com/report attachment://Annual-Report.pdf ``` -------------------------------- ### Reference Filename from Values Panel Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md Refer to a pre-defined filename stored in the Values panel using its key. ```txt pattern attachment://{key-of-values} [lineProps...] [filters...] ``` -------------------------------- ### frameScript Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/frameScript.md Defines the basic syntax for the frameScript rule, including pattern matching and script value types. ```txt pattern frameScript://value [filters...] ``` -------------------------------- ### Inline CSS Body Replacement Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/cssBody.md Demonstrates replacing the response body with inline content. The `resType://css` filter ensures the replacement is treated as CSS. ```txt www.example.com/path1 cssBody://(Hello) file://(-test-) www.example.com/path2 cssBody://(Hello) file://(-test-) resType://js www.example.com/path3 cssBody://(Hello) file://(-test-) resType://css ``` -------------------------------- ### reqWriteRaw Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqWriteRaw.md Defines the basic syntax for the reqWriteRaw rule, specifying the pattern to match the request URL and the destination for storing data. ```txt pattern reqWriteRaw:///fileOrDirPath [filters...] ``` -------------------------------- ### Test Client Error Handling Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/replaceStatus.md Use this to test how clients handle server errors. A 0.1 chance of replacing the status code with 500. ```txt # Test client handling of server errors. www.example.com/api replaceStatus://500 includeFilter://chance:0.1 ``` -------------------------------- ### Protecting Non-Standard HTML Content Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Illustrates using strictHtml and safeHtml modes to prevent corruption of non-HTML content when Content-Type is text/html. ```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://(
Test
) enable://strictHtml ``` -------------------------------- ### Delete Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/delete.md Defines the basic syntax for the delete rule, specifying the pattern to match and the properties to delete. Supports multiple properties separated by '|' or '&'. ```txt pattern delete://prop1|prop2|... [filters...] # Equivalent to: pattern delete://prop1 delete://prop2 ... [filters...] ``` -------------------------------- ### Basic resCors Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Defines the basic syntax for the resCors rule, specifying a pattern to match request URLs and a CORS value. ```txt pattern resCors://value [filters...] ``` -------------------------------- ### Corresponding Response Headers for CORS Object Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Shows the response headers generated based on the provided CORS object structure. ```txt access-control-allow-origin: * access-control-allow-methods: POST access-control-allow-headers: x-test access-control-allow-credentials: true access-control-max-age: 300000 ``` -------------------------------- ### resType Full Type Specification Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resType.md Specifies the full media type and optionally the charset for the `content-type` response header. ```txt # The `content-type` response header becomes `text/plain` www.example.com/path resType://text/plain ``` ```txt # The `content-type` response header becomes `text/plain;charset=utf8` www.example.com/path resType://text/plain;charset=utf8 ``` -------------------------------- ### Allow Credentials with resCors Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Enables cross-origin requests with credentials by setting Access-Control-Allow-Credentials to true and Access-Control-Allow-Origin to the request host. This complies with CORS specifications when credentials are used. ```txt pattern resCors://use-credentials ``` -------------------------------- ### Delete Pathname Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/delete.md Illustrates the syntax for deleting specific segments of a URL's pathname using index-based targeting. ```txt # Basic Format Target Domain delete://pathname.index # Example www.example.com/api/path/to delete://pathname.0 delete://pathname.1 delete://pathname.-1 ``` -------------------------------- ### Test Rate Limiting Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/replaceStatus.md Simulate 'Too Many Requests' scenarios (429). Includes a 'retry-after' header for client guidance. ```txt # Test too many requests scenarios. www.example.com/api/rate-limited replaceStatus://429 resHeaders://retry-after=60 ``` -------------------------------- ### resReplace Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resReplace.md Defines the basic syntax for the resReplace rule, specifying the pattern, the replacement value configuration, and optional filters. ```txt pattern resReplace://value [filters...] ``` -------------------------------- ### Advanced Filtering with Prefixes Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/gui/network.md Utilize prefixes in the search box to filter requests by various criteria such as URL, method, headers, body, IP, status code, and more. Supports keywords and regular expressions. ```txt b:"error":true b:/\d{3}/ app:wechat fc:/test/ e:timeout style:italic ``` ```txt m:pos m:/get\|post/i h:image/ h:/cookie:\s*test=123/i H:example.com H:/test/i i:11.2 i:/^11\.2/ s:404 s:/5\d{2}/ t:json t:/html\|xml/i mark:example.com mark:/\d{5}/ ``` -------------------------------- ### Test Redirect Behavior Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/replaceStatus.md Test permanent and temporary redirect caching. Ensure the Location header is modified when using redirect status codes. ```txt # Test permanent redirect caching. www.example.com/old-page replaceStatus://301 ``` ```txt # Test temporary redirect. www.example.com/temp-redirect replaceStatus://302 ``` -------------------------------- ### HTML Body Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Defines the basic syntax for the htmlBody rule, including pattern, value, and optional filters. ```txt pattern htmlBody://value [filters...] ``` -------------------------------- ### Allow All Origins with resCors Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Configures resCors to allow cross-origin access from any source by setting Access-Control-Allow-Origin to '*'. Suitable for public APIs. ```txt pattern resCors://* ``` -------------------------------- ### CSS Body Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/cssBody.md Defines the basic syntax for the cssBody rule, including pattern matching and value specification. ```txt pattern cssBody://value [filters...] ``` -------------------------------- ### Embedded Value for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Embed complex content with spaces or line breaks using a custom key. This method is recommended for reusability and readability. ```txt pattern resPrepend://{custom-key} [lineProps...] [filters...] ``` custom-key ``` ``` -------------------------------- ### resReplace Inline JSON Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resReplace.md Provides two ways to define inline JSON configurations for the resReplace rule: using a compact format or a more verbose JSON object with escaped characters for regular expressions. ```json user: name /\d+/g: num ``` ```json { 'user': 'name', '/\d+/g': 'num' } ``` -------------------------------- ### Inline Value for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Use inline values for short, simple text content that does not contain spaces or line breaks. ```txt www.example.com/page resPrepend://() ``` -------------------------------- ### reqType Complete Type Specification Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqType.md Specify the complete media type and optionally the charset for the `content-type` header. If charset is not provided, the original charset from the request is retained. ```plaintext www.example.com/path reqType://text/plain # Change the `content-type` in the request header to `text/plain` ``` ```plaintext www.example.com/path reqType://text/plain;charset=utf8 # Change the `content-type` in the request header to `text/plain;charset=utf8` ``` -------------------------------- ### Whistle Rule Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/inherit.md Defines the basic structure for Whistle rules, specifying a pattern to match requests and a value for redirection or transformation, optionally with filters. ```txt pattern //value [filters...] # or pattern value [filters...] ``` -------------------------------- ### Inline/Values CSS Body Replacement Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/cssBody.md Shows how to use embedded content from a file (body.txt) for CSS body replacement. The `resType://css` filter is used to specify the content type. ```txt body.txt Hello world. www.example.com/path1 cssBody://{body.txt} file://(-test-) www.example.com/path2 cssBody://{body.txt} file://(-test-) resType://js www.example.com/path3 cssBody://{body.txt} file://(-test-) resType://css ``` -------------------------------- ### Specify Filename with Embedded Value Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md When filenames are long or need reuse, define them in a code block referenced by a custom key in the rule. ```txt pattern attachment://{custom-key} [lineProps...] [filters...] ``` custom-key Quarterly-Data-2024Q1.csv ``` ``` -------------------------------- ### Disable Path Concatenation for HTTP/HTTPS Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/inherit.md Shows how to disable automatic path concatenation for HTTP/HTTPS conversions by wrapping the target URL in angle brackets or parentheses. ```txt www.example.com/path1 // # www.example.com/path1 //(www.test.com/path/xxx) ``` -------------------------------- ### Attachment Rule with Embedded Filename Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This configuration uses an embedded code block to specify a filename, which is useful for complex or annotated filenames. ```txt https://assets.example.com/data.json attachment://{my-file-name} ``` my-file-name Config-Backup-20240514.json ``` ``` -------------------------------- ### Retrieve Plugin Variables in Hooks Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Access configured plugin variables within plugin hooks using `req.originalReq.globalPluginVars` for global settings and `req.originalReq.pluginVars` for fine-grained settings. ```js req.originalReq.globalPluginVars; // Global variables, such as ['123', 'enableAutoSave=true', 'storageDir=/User/xxx/test/sessions'] ``` ```js req.originalReq.pluginVars; // Variables for fine-grained configuration, such as ['abc', 'enableAutoSave=false', 'storageDir='] ```