Remove Whitespace from HTTP Response Payload
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
}
}Published Jan 30, 2015
Version 1.0hoolio
Cirrostratus
VP of Solutions at WorldTech IT1 Comment
No CommentsBe the first to comment
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)