Differences Between the URL Transformation and HTTP Body Rewrite Features of a NetScaler Virtual Server

Differences Between the URL Transformation and HTTP Body Rewrite Features of a NetScaler Virtual Server

book

Article ID: CTX123094

calendar_today

Updated On:

Description

You use the HTTP body rewrite feature to transform the server response for a resource that is moved to another location. The following is a sample policy and action that rewrites http://example.com to https://example.com:
add rewrite action act1 replace_all "HTTP.RES.BODY(200000)" "\"https://example.com\"" -pattern http://example.com
add rewrite policy pol1 true act1 NOREWRITE
bind rewrite global pol1 10 END -type RES_DEFAULT

Starting NetScaler software release 9.0, you can use the URL transform feature to achieve the same result. The following is a sample URL transform action that is an alternate for the preceding HTTP body rewrite policy:
set transform action act2 -priority 20 -resUrlFrom "http://example.com" -resUrlInto "https://example.com"

Notice that the URL transform action does not have the limitation of the response size from the server.

Chunked Encoding in URL Transformation

Another difference between the HTTP body rewrite and URL transformation feature is handling the content length of the server response to chunked encoding. When URL transformation action is evaluated to be true, the action changes the content length of the server response to chunked encoding. This is so because the URL transformation action verifies and transforms the server response immediately. However, the content length on HTTP body rewrite remains the same.

For a large server response, the NetScaler appliance can perform transformation on multiple units, which are divided internally. As a result, multiple chunks can be the output from a NetScaler virtual server.

The following sample HTTP headers display the difference between the two features:

  • Response from the back end server:

    HTTP/1.1 200 OK\r\n
    Server: generic\r\n
    Content-Length: 65\r\n
    Content-Type: text/html\r\n
    \r\n
    <html><body><p><a href="http://example.com">my link</p></body></html>
  • Output of the NetScaler virtual server configured with HTTP body rewrite

    HTTP/1.1 200 OK\r\n
    Server: generic\r\n
    Content-Length: 66\r\n
    Content-Type: text/html\r\n
    \r\n
    <html><body><p><a href="https://example.com">my link</p></body></html>
  • Output of the NetScaler virtual server configured with URL transformation

    HTTP/1.1 200 OK\r\n
    Server: generic\r\n
    Content-Type: text/html\r\n
    Transfer-Encoding: Chunked\r\n
    42
    <html><body><p><a href="https://example.com">my link</p></body></html>
    0

Issue/Introduction

This article contains differences between the URL transformation and HTTP body rewrite features when configured on a virtual server of a NetScaler appliance.