Section – Rewrite Response Body (any content)
In addition to rewriting the response body for HTML, where the HTML parser of Airlock Gateway Airlock Microgateway lets you define rewrite rules for different semantic parts of HTML, such as URLs and JavaScript, you can configure Gateway Microgateway to generally rewrite the body of HTTP responses.
To specify what bodies shall be rewritten, each rule is accompanied by a Content type field. If a HTTP request or response contains a Content-Type header that matches the regular expression in that field, the rule will be applied.
The configured rewrite rules are executed from top to bottom of the list.
Content type
A response from the back-end server is rewritten only if the response header «Content-Type» matches this regular expression.
Content Pattern
This regular expression pattern defines the content to rewrite. Text parts reusing in Replace with have to marked with parentheses “( )”.
The type specifier ?<URL> right after the opening parenthesis indicates a URL. If URL encryption is enabled, this URL will also be encrypted.
For each pattern the Ignore Case check-box defines if the pattern should be applied case sensitive or not.
Replace with
This is the target string which will replace the string matched by Content Pattern. Substrings marked for reuse in Content Pattern field can be inserted using $1, $2, …
Examples
Purpose | Rewrite URLs in CSS import statements in HTML and CSS documents (type A) |
---|---|
Content Type |
|
Content Pattern |
|
Replace with | $1$2$3 |
Example | HTML snippet from back-end: |
|
|
Purpose | Rewrite URLs in CSS import statements in HTML and CSS documents (type B) |
Content Type |
|
Content Pattern |
|
Replace with | $1$2$3 |
Example | CSS snippet back-end: |