vADC Docs

HowTo: Rewriting HTTP responses

by on ‎02-25-2013 12:47 AM - edited on ‎06-10-2015 09:08 AM by PaulWallace (3,662 Views)

Suppose that you wanted to publish an internal website ( so that it can be accessed externally (with the correct access controls and security of course!). However, the domain name is not valid externally, and you want to refer to the site via the URL


One key requirement is to rewrite any HTML that includes references to, so that they refer to The following response rule will do this:


$url = http.getResponseHeader( "Content-Type" );  
if( !string.startsWith( $url, "text/html" ) ) break;  
$response = http.getResponseBody();  
$response = string.replaceAll( $response,   
  "", "" );  
http.setResponseBody( $response );


http.getResponseBody() and http.setResponseBody() are all that are required to get and set HTTP responses.  These functions take care of the various encodings (e.g. chunk transfer), compression (e.g. gzip) and protocol considerations (e.g. HTTP version, content-length) to ensure that you can reliably manage HTTP responses.


Read more