CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner
hooleylist
Cirrostratus
Cirrostratus

Problem this snippet solves:

Summary: Strip extraneous white space from HTML in the HTTP response payload Here is a simple iRule which uses a stream filter and STREAM::expression based iRule to two or more consecutive whitespace characters with a space. It hasn't been tested in production so try it on a test virtual server or test unit first!

Code :

when HTTP_REQUEST {

       # Prevent server compression
       HTTP::header remove "Accept-Encoding"

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

       # Check if server response is text based
       if { [HTTP::header Content-Type] contains "text" }{

              # Set the stream expression to match two or more consecutive whitespace characters
              # Replace them with a single space
              STREAM::expression @\s+@ @}
              STREAM::enable
       }
}
Comments
JRahm
Community Manager
Community Manager
Contributed by hoolio.
Version history
Last update:
‎30-Jan-2015 05:16
Updated by:
Contributors