cancel
Showing results for 
Search instead for 
Did you mean: 

HowTo: Rewriting HTTP responses

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

 

One key requirement is to rewrite any HTML that includes references to intranet.mycorp.com, so that they refer to extranet.mycorp.com. 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://intranet.mycorp.com/", "https://extranet.mycorp.com/" );  
  
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

 

Version history
Revision #:
1 of 1
Last update:
‎02-25-2013 12:47:AM
Updated by:
 
Labels (1)