How content-length of a HTTP response is handled when rewrite is in use on NetScaler

How content-length of a HTTP response is handled when rewrite is in use on NetScaler

book

Article ID: CTX211605

calendar_today

Updated On:

Description

When using rewrite policy (with priority 120) on NetScaler it can be noticed that Content-Length header is misspelled in the response.
To alter this behavior we can use  another rewrite policy(with priority 100) that has an action that can never be true.

Note: Priority 120 and 100 is taken as examples.
The request of interest is : ( The response for this request will have the HTML file )
GET / HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, /
Accept-Language: en-GB
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; CMDTDF; MS-RTC LM 8)
Accept-Encoding: gzip, deflate
Host: test.example.net
Connection: Keep-Alive

The response for this request in the working scenario is : (between client and NetScaler)

HTTP/1.1 200 OK
Content-Length: 10967
Connection: close
var SERVER_URL = 'https\x3a\x2f\x2ftest.example.net\x2f';
var WEB_SERVER_HOST = 'test.example.net';

Whereas the response for this request in not-working scenario is : (between client and NS)

HTTP/1.1 200 OK
ntCoent-Length: 65244
nnCoection: close
var SERVER_URL = 'https\x3a\x2f\x2ftest.example.net\x2f';
var WEB_SERVER_HOST = 'test.example.net';
 

There is more than one way to indicate the length of a message in HTTP: 
With an explicit Content-Length 
As a chunked message 
Using "FIN termination": the connection is closed once the message is sent and that indicates the end of the message. 
In the above case we have converted a Content-Length into FIN termination. This is because we are streaming the Rewrite changes for the message and don't know the length when we send out the response headers. 
In HTTP the client is supposed to ignore headers that it does not understand. We "corrupt" the Content-Length in the message by permuting the first 4 characters of the header name. This is done so that we don't have to recompute the checksum (which is not changed if the same bytes are in a different order). So this becomes a name of "ntCoent-Length". 

Issue/Introduction

How content-length of a HTTP response is handled when rewrite is in use on NetScaler