Forum Discussion

JosephT's avatar
JosephT
Icon for Nimbostratus rankNimbostratus
Oct 24, 2008

Help write an irule to check and strip transfer-encoding header

We have a need to inspect all http requests and, if an HTTP request contains a Transfer-Encoding header with a value greater than 64 bytes, then we want to remove the Transfer-Encoding header from the HTTP request

 

 

I came up with this:

 

 

when HTTP_REQUEST {

 

if { [HTTP::header exists "Transfer-Encoding"] && [HTTP::header "Transfer-Encoding"] > 64 } {

 

[HTTP::header remove Transfer-Encoding]

 

}

 

}

 

 

But it doesn't appear to be working correctly. When testing, if the HTTP request contains a Transfer-Encoding header (of any size), the HTTP request just never makes it through.

 

 

Any help would be greatly appreciated. TIA!

2 Replies

  • Hi there,

     

     

    If you add logging you could see in /var/log/ltm that [HTTP::header "Transfer-Encoding"] will return the value of the header. If you want to get the length of the header value you could use string length (Click here). Also, you should be getting a TCL error about an unknown command from this line:

     

     

    [HTTP::header remove Transfer-Encoding]

     

     

    The square braces act like backticks in *nix, executing the code within. HTTP::header remove will return 0 or 1 depending on whether it runs successfully. So the braces would be executing 1 which isn't a valid command.

     

     

    This should work:

     

     

     
     when HTTP_REQUEST { 
        if { [HTTP::header exists "Transfer-Encoding"] && [string length [HTTP::header "Transfer-Encoding"]] > 64 } { 
           HTTP::header remove Transfer-Encoding 
        } 
     }  
     

     

     

    Aaron
  • Aaron. Your irule worked perfectly! Thanks for explaining the use of string length and the braces!!!