Rewriting Chunked Responses

Added by Claus Strand , last edited by Claus Strand on Mar 05, 2008  (view change)
Tags: 

The Netscaler Rewrite Module is able to rewrite server responses based on set policies. However, if the responses are chunked, the rewrite function will not work as the Netscaler does not buffer the entire response. Therefore, we need to make sure the server does not send chunked responses.

Summary


In this example, the application was J.D. Edwards and it was discovered that the Netscaler was unable to rewrite chunked responses from the server. This caused issues as the customer was attempting to rewrite outbound body content (using delete_all) but the Netscaler was unable to do so with chunked responses. The first solution was to disable HTTP 1.1 on the web server. While this worked, this solution was not supported by Oracle and as such was not viable. Therefore, we needed a way to disabled chunked responses without modifying the web server. <br>

The solution was to rewrite the inbound browser HTTP version to 1.0 which forces the web server to respond with the full response, not chunked responses.

CLI Command:

 Add rewrite action to replace HTTP Minor with 0:
add rewrite action ReplaceHTTP1.1with1.0 replace http.REQ.VERSION.MINOR "\"0\""

Add rewrite action to delete the HTTP header TE (just a precautionary measure):
add rewrite action DeleteTEHeader delete_http_header TE

Add policy to check for HTTP version. If it's 1.1, replace with 1.0:
add rewrite policy ReplaceHTTP1.1with1.0 "HTTP.REQ.VERSION.CONTAINS(\"1.1\")" ReplaceHTTP1.1with1.0

Add policy to check if the HTTP header TE is present:
add rewrite policy DeleteTEHeader "HTTP.REQ.HEADER(\"TE\").EXISTS" DeleteTEHeader

Bind the policies (note the gotoPriorityExpression to ensure both policies are evaluated):
bind lb vserver HTTPVIP -policyName ReplaceHTTP1.1with1.0 -priority 1 -gotoPriorityExpression END -type REQUEST
bind lb vserver HTTPVIP -policyName DeleteTEHeader -priority 2 -gotoPriorityExpression NEXT -type REQUEST

At this point, the server should not respond with chunked responses and you should be able create rewrite policies/actions to rewrite response side content.

*It is important to note that the Netscaler may still respond to the client with a chunked response although the server responded with non-chunked. This is okay as the rewrite occurs before the Netscaler sends out the chunked response*

 

More Information