Showing results for 
Search instead for 
Did you mean: 

How to Send html file file extra

Occasional Contributor

How to Send html file file extra

How to send a HTML file that is stored on the extra folder on STM from the user url request?


Re: How to Send html file file extra


    You can use the resource.get() function to read the contents of the file then send it to the user with http.setResponseBody() function.

resource.get( filename )

Returns the contents of a named file stored in the ZEUSHOME/zxtm/conf/extra/ directory. If the file doesn't exist, then an empty string is returned. Note that subdirectories of conf/extra are not supported.
Resources are pre-loaded into memory, so this call does not cause the file to be reloaded.

# Read the contents of the 'info' file and add them
# as a new header.
http.addheader( "X-Info", resource.get( "info" ));

http.setResponseBody( body, [transfer-encoding] )

Sets the response body for this HTTP response to the supplied string, replacing any response body already present.
This also updates the 'Content-Length' header in the response to the length of the new body data. In addition the 'Content-Encoding' header is removed as we only ever set body data which is not encoded or compressed. If the server is still sending the original response body when this function is called, the connection to the server will be harmlessly dropped.
The optional 'transfer-encoding' parameter indicates the encoding of the body data (for example, 'chunked').

$body = http.getResponseBody( 0 );
$body = string.regexsub( $body, "Buy", "Sell", "g" );
http.setResponseBody( $body );
Aidan Clarke
Pulse Secure vADC Product Manager
Occasional Contributor

Re: How to Send html file file extra


# Function Looks for /akamai-sureroute-test-object.html Test Page


# Date: 2012.12.17

# By: rhp

# Usage: In other Traffic Scripts add the following line:

# import SureRoute_TestPage;



if (string.wildmatch(http.getRequest(),"*/akamai-sureroute-test-object.html*")){"Path Match is Test");


   $file = "sureroute-test-object.html" ;

   if( resource.exists( $file ) ) {

      $html = "";

      $body = resource.getLines( $file );                

      foreach ( $line in $body ) {

         $html .= $line;


      #$body = resource.get( "$file" );              "Sure Route Test File found.");



      "text/html", $html,





   } else {"Sure Route Test File not found.");




Re: How to Send html file file extra

Hi Richard,

Just a couple of recommendations....

1. You don't need to stitch the file together line by line. You can just use resource.get() to load the whole file at once.

2. http.sendResponse() terminates processing and sends the data to the client, therfore you don't need to include the connection.discard() or the break.