cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.
hooleylist
Cirrostratus
Cirrostratus

Problem this snippet solves:

This example uses similar logic to scrub out HTML comments as the Html Comment Scrubber rule. Instead of collecting the HTTP response payloads, it uses the stream filter to replace the strings inline. This should be more efficient than buffering the entire payload with the HTTP::collect command.

How to use this snippet:

The iRule requires a blank stream profile and a custom HTTP profile with Chunking set to Rechunk if you change the response content length.

Code :

when HTTP_REQUEST {

# Prevent the server from sending chunked response data
if { [HTTP::version] eq "1.1" } {

# Force downgrade to HTTP 1.0, but still allow keep-alive connections.
# Since HTTP 1.1 is keep-alive by default, and 1.0 is not,
# we need make sure the headers reflect the keep-alive status.
if { [HTTP::header is_keepalive] } {
  HTTP::header replace "Connection" "Keep-Alive"
}
}

# Disable the stream filter by default
STREAM::disable
}
when HTTP_RESPONSE {

# Check if the response is HTML
if {[HTTP::header "Content-Type"] contains html{

# Set the stream expression to match HTML comments and replace them with nothing
STREAM::expression {###}
STREAM::enable
}
}
# STREAM_MATCHED is triggered when the stream filter find string is found
when STREAM_MATCHED {

   # Log the string which matched the stream profile
   log local0. "[IP::client_addr]:[TCP::client_port]: Removed comment: [STREAM::match]"
}

Tested this on version:

10.0
Version history
Last update:
‎30-Jan-2015 05:05
Updated by:
Contributors